Page Speed Optimization Libraries  1.9.32.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
apr_file_system.h
Go to the documentation of this file.
1 // Copyright 2010 Google Inc.
16 
17 #ifndef NET_INSTAWEB_APACHE_APR_FILE_SYSTEM_H_
18 #define NET_INSTAWEB_APACHE_APR_FILE_SYSTEM_H_
19 
20 #include "apr.h"
21 
26 
27 struct apr_finfo_t;
28 struct apr_pool_t;
29 
30 namespace net_instaweb {
31 
32 class AbstractMutex;
33 class MessageHandler;
34 class ThreadSystem;
35 class Timer;
36 
37 void AprReportError(MessageHandler* message_handler, const char* filename,
38  int line, const char* message, int error_code);
39 
40 class AprFileSystem : public FileSystem {
41  public:
42  AprFileSystem(apr_pool_t* pool, ThreadSystem* thread_system);
43  ~AprFileSystem();
44 
45  virtual int MaxPathLength(const StringPiece& base) const;
46  virtual InputFile* OpenInputFile(
47  const char* file, MessageHandler* message_handler);
48  virtual OutputFile* OpenOutputFileHelper(
49  const char* file, bool append, MessageHandler* message_handler);
51  virtual OutputFile* OpenTempFileHelper(const StringPiece& prefix_name,
52  MessageHandler* message_handler);
53 
54  virtual bool ListContents(const StringPiece& dir, StringVector* files,
55  MessageHandler* handler);
58  virtual bool MakeDir(const char* directory_path, MessageHandler* handler);
59  virtual bool RemoveDir(const char* directory_path,
60  MessageHandler* message_handler);
61  virtual bool RemoveFile(const char* filename,
62  MessageHandler* message_handler);
63  virtual bool RenameFileHelper(const char* old_filename,
64  const char* new_filename,
65  MessageHandler* message_handler);
66 
67  virtual bool Atime(const StringPiece& path,
68  int64* timestamp_sec, MessageHandler* handler);
69  virtual bool Mtime(const StringPiece& path,
70  int64* timestamp_sec, MessageHandler* handler);
74  virtual bool Size(const StringPiece& path, int64* size,
75  MessageHandler* handler);
76  virtual BoolOrError Exists(const char* path, MessageHandler* handler);
77  virtual BoolOrError IsDir(const char* path, MessageHandler* handler);
78 
79  virtual BoolOrError TryLock(const StringPiece& lock_name,
80  MessageHandler* handler);
81  virtual BoolOrError TryLockWithTimeout(const StringPiece& lock_name,
82  int64 timeout_ms,
83  const Timer* timer,
84  MessageHandler* handler);
85  virtual bool Unlock(const StringPiece& lock_name, MessageHandler* handler);
86 
87  private:
89  bool Stat(const StringPiece& path,
90  apr_finfo_t* file_info, apr_int32_t field_wanted,
91  MessageHandler* handler);
92 
93  apr_pool_t* pool_;
94 
98  scoped_ptr<AbstractMutex> mutex_;
99 
100  DISALLOW_COPY_AND_ASSIGN(AprFileSystem);
101 };
102 
103 }
104 
105 #endif
virtual bool MakeDir(const char *directory_path, MessageHandler *handler)
virtual OutputFile * OpenTempFileHelper(const StringPiece &prefix_name, MessageHandler *message_handler)
See FileSystem interface for specifics of OpenTempFile.
virtual bool Size(const StringPiece &path, int64 *size, MessageHandler *handler)
Definition: apr_file_system.h:40