Page Speed Optimization Libraries
1.5.27.2
|
00001 /* 00002 * Copyright 2010 Google Inc. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http:///www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 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 class Timer; 00032 00033 class StdioFileSystem : public FileSystem { 00034 public: 00035 StdioFileSystem() {} 00036 virtual ~StdioFileSystem(); 00037 00038 virtual int MaxPathLength(const StringPiece& base) const; 00039 00040 virtual InputFile* OpenInputFile(const char* filename, 00041 MessageHandler* message_handler); 00042 virtual OutputFile* OpenOutputFileHelper(const char* filename, 00043 bool append, 00044 MessageHandler* message_handler); 00045 virtual OutputFile* OpenTempFileHelper(const StringPiece& prefix_name, 00046 MessageHandler* message_handle); 00047 00048 virtual bool ListContents(const StringPiece& dir, StringVector* files, 00049 MessageHandler* handler); 00050 virtual bool MakeDir(const char* directory_path, MessageHandler* handler); 00051 virtual bool RemoveDir(const char* directory_path, MessageHandler* handler); 00052 virtual bool RemoveFile(const char* filename, MessageHandler* handler); 00053 virtual bool RenameFileHelper(const char* old_file, const char* new_file, 00054 MessageHandler* handler); 00055 00056 virtual bool Atime(const StringPiece& path, int64* timestamp_sec, 00057 MessageHandler* handler); 00058 virtual bool Mtime(const StringPiece& path, int64* timestamp_sec, 00059 MessageHandler* handler); 00063 virtual bool Size(const StringPiece& path, int64* size, 00064 MessageHandler* handler); 00065 virtual BoolOrError Exists(const char* path, MessageHandler* handler); 00066 virtual BoolOrError IsDir(const char* path, MessageHandler* handler); 00067 00068 virtual BoolOrError TryLock(const StringPiece& lock_name, 00069 MessageHandler* handler); 00070 virtual BoolOrError TryLockWithTimeout(const StringPiece& lock_name, 00071 int64 timeout_ms, 00072 const Timer* timer, 00073 MessageHandler* handler); 00074 00075 virtual bool Unlock(const StringPiece& lock_name, MessageHandler* handler); 00076 00077 InputFile* Stdin(); 00078 OutputFile* Stdout(); 00079 OutputFile* Stderr(); 00080 00081 private: 00083 bool Stat(const StringPiece& path, struct stat* statbuf, 00084 MessageHandler* handler); 00085 00086 DISALLOW_COPY_AND_ASSIGN(StdioFileSystem); 00087 }; 00088 00089 } 00090 00091 #endif ///< NET_INSTAWEB_UTIL_PUBLIC_STDIO_FILE_SYSTEM_H_