Page Speed Optimization Libraries  1.7.30.2
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 class Timer;
00036 
00037 void AprReportError(MessageHandler* message_handler, const char* filename,
00038                     int line, const char* message, int error_code);
00039 
00040 class AprFileSystem : public FileSystem {
00041  public:
00042   AprFileSystem(apr_pool_t* pool, ThreadSystem* thread_system);
00043   ~AprFileSystem();
00044 
00045   virtual int MaxPathLength(const StringPiece& base) const;
00046   virtual InputFile* OpenInputFile(
00047       const char* file, MessageHandler* message_handler);
00048   virtual OutputFile* OpenOutputFileHelper(
00049       const char* file, bool append, MessageHandler* message_handler);
00051   virtual OutputFile* OpenTempFileHelper(const StringPiece& prefix_name,
00052                                          MessageHandler* message_handler);
00053 
00054   virtual bool ListContents(const StringPiece& dir, StringVector* files,
00055                             MessageHandler* handler);
00058   virtual bool MakeDir(const char* directory_path, MessageHandler* handler);
00059   virtual bool RemoveDir(const char* directory_path,
00060                          MessageHandler* message_handler);
00061   virtual bool RemoveFile(const char* filename,
00062                           MessageHandler* message_handler);
00063   virtual bool RenameFileHelper(const char* old_filename,
00064                                 const char* new_filename,
00065                                 MessageHandler* message_handler);
00066 
00067   virtual bool Atime(const StringPiece& path,
00068                      int64* timestamp_sec, MessageHandler* handler);
00069   virtual bool Mtime(const StringPiece& path,
00070                      int64* timestamp_sec, MessageHandler* handler);
00074   virtual bool Size(const StringPiece& path, int64* size,
00075                     MessageHandler* handler);
00076   virtual BoolOrError Exists(const char* path, MessageHandler* handler);
00077   virtual BoolOrError IsDir(const char* path, MessageHandler* handler);
00078 
00079   virtual BoolOrError TryLock(const StringPiece& lock_name,
00080                               MessageHandler* handler);
00081   virtual BoolOrError TryLockWithTimeout(const StringPiece& lock_name,
00082                                          int64 timeout_ms,
00083                                          const Timer* timer,
00084                                          MessageHandler* handler);
00085   virtual bool Unlock(const StringPiece& lock_name, MessageHandler* handler);
00086 
00087  private:
00089   bool Stat(const StringPiece& path,
00090             apr_finfo_t* file_info, apr_int32_t field_wanted,
00091             MessageHandler* handler);
00092 
00093   apr_pool_t* pool_;
00094 
00098   scoped_ptr<AbstractMutex> mutex_;
00099 
00100   DISALLOW_COPY_AND_ASSIGN(AprFileSystem);
00101 };
00102 
00103 }  
00104 
00105 #endif  ///< NET_INSTAWEB_APACHE_APR_FILE_SYSTEM_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines