diff options
Diffstat (limited to 'base/file_util.cc')
-rw-r--r-- | base/file_util.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/base/file_util.cc b/base/file_util.cc index 10e08d5..1cf22b7 100644 --- a/base/file_util.cc +++ b/base/file_util.cc @@ -275,6 +275,29 @@ bool CloseFile(FILE* file) { return fclose(file) == 0; } +/////////////////////////////////////////////// +// MemoryMappedFile + +MemoryMappedFile::~MemoryMappedFile() { + CloseHandles(); +} + +bool MemoryMappedFile::Initialize(const FilePath& file_name) { + if (IsValid()) + return false; + + if (!MapFileToMemory(file_name)) { + CloseHandles(); + return false; + } + + return true; +} + +bool MemoryMappedFile::IsValid() { + return data_ != NULL; +} + // Deprecated functions ---------------------------------------------------- bool AbsolutePath(std::wstring* path_str) { |