00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00018
00019 #ifndef NET_INSTAWEB_UTIL_PUBLIC_STDIO_FILE_SYSTEM_H_
00020 #define NET_INSTAWEB_UTIL_PUBLIC_STDIO_FILE_SYSTEM_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/string_util.h"
00025
00026 struct stat;
00027
00028 namespace net_instaweb {
00029
00030 class MessageHandler;
00031
00032 class StdioFileSystem : public FileSystem {
00033 public:
00034 StdioFileSystem() {}
00035 virtual ~StdioFileSystem();
00036
00037 virtual int MaxPathLength(const StringPiece& base) const;
00038
00039 virtual InputFile* OpenInputFile(const char* filename,
00040 MessageHandler* message_handler);
00041 virtual OutputFile* OpenOutputFileHelper(const char* filename,
00042 MessageHandler* message_handler);
00043 virtual OutputFile* OpenTempFileHelper(const StringPiece& prefix_name,
00044 MessageHandler* message_handle);
00045
00046 virtual bool ListContents(const StringPiece& dir, StringVector* files,
00047 MessageHandler* handler);
00048 virtual bool MakeDir(const char* directory_path, MessageHandler* handler);
00049 virtual bool RemoveFile(const char* filename, MessageHandler* handler);
00050 virtual bool RenameFileHelper(const char* old_file, const char* new_file,
00051 MessageHandler* handler);
00052
00053 virtual bool Atime(const StringPiece& path, int64* timestamp_sec,
00054 MessageHandler* handler);
00055 virtual bool Mtime(const StringPiece& path, int64* timestamp_sec,
00056 MessageHandler* handler);
00057 virtual bool Size(const StringPiece& path, int64* size,
00058 MessageHandler* handler);
00059 virtual BoolOrError Exists(const char* path, MessageHandler* handler);
00060 virtual BoolOrError IsDir(const char* path, MessageHandler* handler);
00061
00062 virtual BoolOrError TryLock(const StringPiece& lock_name,
00063 MessageHandler* handler);
00064 virtual bool Unlock(const StringPiece& lock_name, MessageHandler* handler);
00065
00066 InputFile* Stdin();
00067 OutputFile* Stdout();
00068 OutputFile* Stderr();
00069
00070 private:
00072 bool Stat(const StringPiece& path, struct stat* statbuf,
00073 MessageHandler* handler);
00074
00075 DISALLOW_COPY_AND_ASSIGN(StdioFileSystem);
00076 };
00077
00078 }
00079
00080 #endif ///< NET_INSTAWEB_UTIL_PUBLIC_STDIO_FILE_SYSTEM_H_