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
CrOS-Libchrome-Original-Commit: fd55c28d08f5daef2938cc8ec956849fa80ffcbb
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 @@
// 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 @@
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 @@
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 */,