diff options
author | rvargas@chromium.org <rvargas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-18 17:56:38 +0000 |
---|---|---|
committer | rvargas@chromium.org <rvargas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-18 17:56:38 +0000 |
commit | e49597018bf66ca87d3e864482f64473ea92399e (patch) | |
tree | 0139a446aad778c6c84addafa8c4ec9036d56b23 /chrome/browser/extensions/api/file_handlers | |
parent | bff4ff94f311adae0b622603029efdf4a8a8df2c (diff) | |
download | chromium_src-e49597018bf66ca87d3e864482f64473ea92399e.zip chromium_src-e49597018bf66ca87d3e864482f64473ea92399e.tar.gz chromium_src-e49597018bf66ca87d3e864482f64473ea92399e.tar.bz2 |
Remove CreatePlatformFile from browser/extensions
BUG=322664
Review URL: https://codereview.chromium.org/193603002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257686 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/api/file_handlers')
-rw-r--r-- | chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc b/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc index 9d0a5cd..f79af9f 100644 --- a/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc +++ b/chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc @@ -5,6 +5,7 @@ #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" #include "base/file_util.h" +#include "base/files/file.h" #include "base/files/file_path.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/child_process_security_policy.h" @@ -73,21 +74,12 @@ bool DoCheckWritableFile(const base::FilePath& path, bool is_directory) { return base::DirectoryExists(path); // Create the file if it doesn't already exist. - base::PlatformFileError error = base::PLATFORM_FILE_OK; - int creation_flags = base::PLATFORM_FILE_CREATE | - base::PLATFORM_FILE_READ | - base::PLATFORM_FILE_WRITE; - base::PlatformFile file = base::CreatePlatformFile(path, creation_flags, - NULL, &error); - // Close the file so we don't keep a lock open. - if (file != base::kInvalidPlatformFileValue) - base::ClosePlatformFile(file); - if (error != base::PLATFORM_FILE_OK && - error != base::PLATFORM_FILE_ERROR_EXISTS) { - return false; - } - - return true; + int creation_flags = base::File::FLAG_CREATE | base::File::FLAG_READ | + base::File::FLAG_WRITE; + base::File file(path, creation_flags); + if (file.IsValid()) + return true; + return file.error_details() == base::File::FILE_ERROR_EXISTS; } // Checks whether a list of paths are all OK for writing and calls a provided |