summaryrefslogtreecommitdiffstats
path: root/base/file_util_proxy.h
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-15 00:37:34 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-15 00:37:34 +0000
commitfd55c28d08f5daef2938cc8ec956849fa80ffcbb (patch)
treeb36eec5e70c97649b570ef6395549c043b1ad3fd /base/file_util_proxy.h
parent1a47d7ea5a641b185283228692c2767a69f09e1a (diff)
downloadchromium_src-fd55c28d08f5daef2938cc8ec956849fa80ffcbb.zip
chromium_src-fd55c28d08f5daef2938cc8ec956849fa80ffcbb.tar.gz
chromium_src-fd55c28d08f5daef2938cc8ec956849fa80ffcbb.tar.bz2
Rename FileUtilProxy::Create to EnsureFileExists
per follow-up discussion on http://codereview.chromium.org/3717001/show Rename FileUtilProxy::Create to EnsureFileExists to make it clear that it doesn't open the file (or doesn't leave a file handle opened). Also fixes CreatePlatformFile to set |created| correctly when PLATFORM_FILE_CREATE flag is given (I think this is the correct behavior). BUG=none TEST=FileSystemOperationTest.* Review URL: http://codereview.chromium.org/3743004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62683 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util_proxy.h')
-rw-r--r--base/file_util_proxy.h26
1 files changed, 19 insertions, 7 deletions
diff --git a/base/file_util_proxy.h b/base/file_util_proxy.h
index 11fc988..09c2377 100644
--- a/base/file_util_proxy.h
+++ b/base/file_util_proxy.h
@@ -40,6 +40,9 @@ class FileUtilProxy {
// Creates or opens a file with the given flags. It is invalid to pass NULL
// for the callback.
+ // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create
+ // a new file at the given |file_path| and calls back with
+ // PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists.
typedef Callback3<base::PlatformFileError /* error code */,
base::PassPlatformFile,
bool /* created */>::Type CreateOrOpenCallback;
@@ -48,13 +51,6 @@ class FileUtilProxy {
int file_flags,
CreateOrOpenCallback* callback);
- // Creates a file with the given flags. This one is a variation of
- // CreateOrOpen but it doesn't return a file handle.
- static bool Create(scoped_refptr<MessageLoopProxy> message_loop_proxy,
- const FilePath& file_path,
- int file_flags,
- CreateOrOpenCallback* callback);
-
// Creates a temporary file for writing. The path and an open file handle
// are returned. It is invalid to pass NULL for the callback.
typedef Callback3<base::PlatformFileError /* error code */,
@@ -69,6 +65,22 @@ class FileUtilProxy {
base::PlatformFile,
StatusCallback* callback);
+ // Ensures that the given |file_path| exist. This creates a empty new file
+ // at |file_path| if the |file_path| does not exist.
+ // If a new file han not existed and is created at the |file_path|,
+ // |created| of the callback argument is set true and |error code|
+ // is set PLATFORM_FILE_OK.
+ // If the file already exists, |created| is set false and |error code|
+ // is set PLATFORM_FILE_OK.
+ // If the file hasn't existed but it couldn't be created for some other
+ // reasons, |created| is set false and |error code| indicates the error.
+ typedef Callback2<base::PlatformFileError /* error code */,
+ bool /* created */>::Type EnsureFileExistsCallback;
+ static bool EnsureFileExists(
+ scoped_refptr<MessageLoopProxy> message_loop_proxy,
+ const FilePath& file_path,
+ EnsureFileExistsCallback* callback);
+
// Retrieves the information about a file. It is invalid to pass NULL for the
// callback.
typedef Callback2<base::PlatformFileError /* error code */,