diff options
author | ericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-13 21:56:32 +0000 |
---|---|---|
committer | ericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-13 21:56:32 +0000 |
commit | d4905e2e68cb434f9b3cbea9726eeaf23b1ecb00 (patch) | |
tree | 0252099f7e9b2eaa1f0df3166da7933d761b4b55 /base | |
parent | 067a16671a1faf2f460f5ebbddfbfb5d933c5cec (diff) | |
download | chromium_src-d4905e2e68cb434f9b3cbea9726eeaf23b1ecb00.zip chromium_src-d4905e2e68cb434f9b3cbea9726eeaf23b1ecb00.tar.gz chromium_src-d4905e2e68cb434f9b3cbea9726eeaf23b1ecb00.tar.bz2 |
ObfuscatedFileSystemFileUtil class
This is functional and reasonably well-tested, but we'll still have to adapt the system a bit in order to use it.
BUG=none
TEST=included unit tests
Review URL: http://codereview.chromium.org/6955013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85332 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/platform_file.h | 7 | ||||
-rw-r--r-- | base/platform_file_posix.cc | 10 | ||||
-rw-r--r-- | base/platform_file_win.cc | 4 |
3 files changed, 12 insertions, 9 deletions
diff --git a/base/platform_file.h b/base/platform_file.h index 461b060..dbac61a 100644 --- a/base/platform_file.h +++ b/base/platform_file.h @@ -96,9 +96,10 @@ struct BASE_API PlatformFileInfo { base::Time creation_time; }; -// Creates or opens the given file. If PLATFORM_FILE_OPEN_ALWAYS is used, and -// |created| is provided, |created| will be set to true if the file was created -// or to false in case the file was just opened. |error_code| can be NULL. +// Creates or opens the given file. If |created| is provided, it will be set to +// true if a new file was created [or an old one truncated to zero length to +// simulate a new file, which can happen with PLATFORM_FILE_CREATE_ALWAYS], and +// false otherwise. |error_code| can be NULL. BASE_API PlatformFile CreatePlatformFile(const FilePath& name, int flags, bool* created, diff --git a/base/platform_file_posix.cc b/base/platform_file_posix.cc index 6e2cff6..2ffac06 100644 --- a/base/platform_file_posix.cc +++ b/base/platform_file_posix.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -36,6 +36,9 @@ PlatformFile CreatePlatformFile(const FilePath& name, int flags, if (flags & PLATFORM_FILE_CREATE) open_flags = O_CREAT | O_EXCL; + if (created) + *created = false; + if (flags & PLATFORM_FILE_CREATE_ALWAYS) { DCHECK(!open_flags); open_flags = O_CREAT | O_TRUNC; @@ -70,10 +73,7 @@ PlatformFile CreatePlatformFile(const FilePath& name, int flags, HANDLE_EINTR(open(name.value().c_str(), open_flags, S_IRUSR | S_IWUSR)); if (flags & PLATFORM_FILE_OPEN_ALWAYS) { - if (descriptor > 0) { - if (created) - *created = false; - } else { + if (descriptor <= 0) { open_flags |= O_CREAT; if (flags & PLATFORM_FILE_EXCLUSIVE_READ || flags & PLATFORM_FILE_EXCLUSIVE_WRITE) { diff --git a/base/platform_file_win.cc b/base/platform_file_win.cc index 0cb3e53..7a6a586 100644 --- a/base/platform_file_win.cc +++ b/base/platform_file_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,6 +17,8 @@ PlatformFile CreatePlatformFile(const FilePath& name, base::ThreadRestrictions::AssertIOAllowed(); DWORD disposition = 0; + if (created) + *created = false; if (flags & PLATFORM_FILE_OPEN) disposition = OPEN_EXISTING; |