7 #ifndef PACKAGER_FILE_FILE_H_
8 #define PACKAGER_FILE_FILE_H_
14 #include "packager/base/macros.h"
16 namespace edash_packager {
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_; }
113 static bool Copy(
const char* from_file_name,
const char* to_file_name);
129 explicit File(
const std::string& file_name) : file_name_(file_name) {}
135 virtual bool Open() = 0;
142 static File* Create(
const char* file_name,
const char* mode);
144 static File* CreateInternalFile(
const char* file_name,
const char* mode);
146 std::string file_name_;
147 DISALLOW_COPY_AND_ASSIGN(
File);
153 #endif // PACKAGER_FILE_FILE_H_