summaryrefslogtreecommitdiffstats
path: root/base/file_util.cc
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-12 23:43:03 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-12 23:43:03 +0000
commit7856bb83df917cfaebfe7881dc620bf264a94885 (patch)
tree441a77bf222db624ec3c3bbf58f0f3f9698befd9 /base/file_util.cc
parent6d2b8132aaa55a9e01b8b49bcce5eb44c68a1972 (diff)
downloadchromium_src-7856bb83df917cfaebfe7881dc620bf264a94885.zip
chromium_src-7856bb83df917cfaebfe7881dc620bf264a94885.tar.gz
chromium_src-7856bb83df917cfaebfe7881dc620bf264a94885.tar.bz2
revert r6938
(i.e. reapply 6935, with fix) Review URL: http://codereview.chromium.org/14087 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6953 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util.cc')
-rw-r--r--base/file_util.cc23
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) {