Page Speed Optimization Libraries  1.4.26.1
net/instaweb/apache/apr_file_system.h
Go to the documentation of this file.
00001 // Copyright 2010 Google Inc.
00016 
00017 #ifndef NET_INSTAWEB_APACHE_APR_FILE_SYSTEM_H_
00018 #define NET_INSTAWEB_APACHE_APR_FILE_SYSTEM_H_
00019 
00020 #include "apr.h"
00021 
00022 #include "net/instaweb/util/public/basictypes.h"
00023 #include "net/instaweb/util/public/file_system.h"
00024 #include "net/instaweb/util/public/scoped_ptr.h"
00025 #include "net/instaweb/util/public/string_util.h"
00026 
00027 struct apr_finfo_t;
00028 struct apr_pool_t;
00029 
00030 namespace net_instaweb {
00031 
00032 class AbstractMutex;
00033 class MessageHandler;
00034 class ThreadSystem;
00035 
00036 void AprReportError(MessageHandler* message_handler, const char* filename,
00037                     int line, const char* message, int error_code);
00038 
00039 class AprFileSystem : public FileSystem {
00040  public:
00041   AprFileSystem(apr_pool_t* pool, ThreadSystem* thread_system);
00042   ~AprFileSystem();
00043 
00044   virtual int MaxPathLength(const StringPiece& base) const;
00045   virtual InputFile* OpenInputFile(
00046       const char* file, MessageHandler* message_handler);
00047   virtual OutputFile* OpenOutputFileHelper(
00048       const char* file, bool append, MessageHandler* message_handler);
00050   virtual OutputFile* OpenTempFileHelper(const StringPiece& prefix_name,
00051                                          MessageHandler* message_handler);
00052 
00053   virtual bool ListContents(const StringPiece& dir, StringVector* files,
00054                             MessageHandler* handler);
00057   virtual bool MakeDir(const char* directory_path, MessageHandler* handler);
00058   virtual bool RemoveDir(const char* directory_path,
00059                          MessageHandler* message_handler);
00060   virtual bool RemoveFile(const char* filename,
00061                           MessageHandler* message_handler);
00062   virtual bool RenameFileHelper(const char* old_filename,
00063                                 const char* new_filename,
00064                                 MessageHandler* message_handler);
00065 
00066   virtual bool Atime(const StringPiece& path,
00067                      int64* timestamp_sec, MessageHandler* handler);
00068   virtual bool Mtime(const StringPiece& path,
00069                      int64* timestamp_sec, MessageHandler* handler);
00073   virtual bool Size(const StringPiece& path, int64* size,
00074                     MessageHandler* handler);
00075   virtual BoolOrError Exists(const char* path, MessageHandler* handler);
00076   virtual BoolOrError IsDir(const char* path, MessageHandler* handler);
00077 
00078   virtual BoolOrError TryLock(const StringPiece& lock_name,
00079                               MessageHandler* handler);
00080   virtual BoolOrError TryLockWithTimeout(const StringPiece& lock_name,
00081                                          int64 timeout_ms,
00082                                          MessageHandler* handler);
00083   virtual bool Unlock(const StringPiece& lock_name, MessageHandler* handler);
00084 
00085  private:
00087   bool Stat(const StringPiece& path,
00088             apr_finfo_t* file_info, apr_int32_t field_wanted,
00089             MessageHandler* handler);
00090 
00091   apr_pool_t* pool_;
00092 
00096   scoped_ptr<AbstractMutex> mutex_;
00097 
00098   DISALLOW_COPY_AND_ASSIGN(AprFileSystem);
00099 };
00100 
00101 }  
00102 
00103 #endif  ///< NET_INSTAWEB_APACHE_APR_FILE_SYSTEM_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines