7 #ifndef PACKAGER_FILE_FILE_H_
8 #define PACKAGER_FILE_FILE_H_
14 #include "packager/base/macros.h"
19 extern const char* kLocalFilePrefix;
20 extern const char* kMemoryFilePrefix;
21 const int64_t kWholeFile = -1;
45 static bool Delete(
const char* file_name);
52 virtual bool Close() = 0;
60 virtual int64_t
Read(
void* buffer, uint64_t length) = 0;
66 virtual int64_t
Write(
const void* buffer, uint64_t length) = 0;
70 virtual int64_t
Size() = 0;
77 virtual bool Flush() = 0;
82 virtual bool Seek(uint64_t position) = 0;
88 virtual bool Tell(uint64_t* position) = 0;
91 const std::string&
file_name()
const {
return file_name_; }
112 const std::string& contents);
120 static bool Copy(
const char* from_file_name,
const char* to_file_name);
136 explicit File(
const std::string& file_name) : file_name_(file_name) {}
142 virtual bool Open() = 0;
149 static File* Create(
const char* file_name,
const char* mode);
151 static File* CreateInternalFile(
const char* file_name,
const char* mode);
153 std::string file_name_;
154 DISALLOW_COPY_AND_ASSIGN(
File);
160 #endif // PACKAGER_FILE_FILE_H_