diff options
author | tzik@chromium.org <tzik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-13 07:39:14 +0000 |
---|---|---|
committer | tzik@chromium.org <tzik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-13 07:39:14 +0000 |
commit | 13f92f6ef44255616d83cf302e69be34958f00c9 (patch) | |
tree | b42b139bc208cef7722fb8d94b26a5021d1a3c86 /webkit/fileapi/file_util_helper.cc | |
parent | 51ad8e16809a4de8bfcd72fcfdfd1339276d65a5 (diff) | |
download | chromium_src-13f92f6ef44255616d83cf302e69be34958f00c9.zip chromium_src-13f92f6ef44255616d83cf302e69be34958f00c9.tar.gz chromium_src-13f92f6ef44255616d83cf302e69be34958f00c9.tar.bz2 |
Remove FileSystemFileUtil::{Directory,Path}Exists
They were used in file_util_helper.cc and by tests only, and is not needed to exist separate implementation per FileUtil.
Can I remove it like this?
BUG=
Review URL: https://chromiumcodereview.appspot.com/10855039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151234 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/file_util_helper.cc')
-rw-r--r-- | webkit/fileapi/file_util_helper.cc | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/webkit/fileapi/file_util_helper.cc b/webkit/fileapi/file_util_helper.cc index 651220b4..b2e0c08 100644 --- a/webkit/fileapi/file_util_helper.cc +++ b/webkit/fileapi/file_util_helper.cc @@ -105,14 +105,14 @@ base::PlatformFileError CrossFileUtilHelper::DoWork() { base::PlatformFileError error = PerformErrorCheckAndPreparation(); if (error != base::PLATFORM_FILE_OK) return error; - if (src_util_->DirectoryExists(context_, src_root_url_)) + if (FileUtilHelper::DirectoryExists(context_, src_util_, src_root_url_)) return CopyOrMoveDirectory(src_root_url_, dest_root_url_); return CopyOrMoveFile(src_root_url_, dest_root_url_); } PlatformFileError CrossFileUtilHelper::PerformErrorCheckAndPreparation() { // Exits earlier if the source path does not exist. - if (!src_util_->PathExists(context_, src_root_url_)) + if (!FileUtilHelper::PathExists(context_, src_util_, src_root_url_)) return base::PLATFORM_FILE_ERROR_NOT_FOUND; // The parent of the |dest_root_url_| does not exist. @@ -124,14 +124,15 @@ PlatformFileError CrossFileUtilHelper::PerformErrorCheckAndPreparation() { return base::PLATFORM_FILE_ERROR_INVALID_OPERATION; // Now it is ok to return if the |dest_root_url_| does not exist. - if (!dest_util_->PathExists(context_, dest_root_url_)) + if (!FileUtilHelper::PathExists(context_, dest_util_, dest_root_url_)) return base::PLATFORM_FILE_OK; // |src_root_url_| exists and is a directory. // |dest_root_url_| exists and is a file. - bool src_is_directory = src_util_->DirectoryExists(context_, src_root_url_); + bool src_is_directory = + FileUtilHelper::DirectoryExists(context_, src_util_, src_root_url_); bool dest_is_directory = - dest_util_->DirectoryExists(context_, dest_root_url_); + FileUtilHelper::DirectoryExists(context_, dest_util_, dest_root_url_); // Either one of |src_root_url_| or |dest_root_url_| is directory, // while the other is not. @@ -165,7 +166,8 @@ bool CrossFileUtilHelper::ParentExists( FilePath parent = url.path().DirName(); if (parent == FilePath(FILE_PATH_LITERAL("."))) return true; - return file_util->DirectoryExists(context_, url.WithPath(parent)); + return FileUtilHelper::DirectoryExists(context_, file_util, + url.WithPath(parent)); } PlatformFileError CrossFileUtilHelper::CopyOrMoveDirectory( @@ -285,6 +287,31 @@ PlatformFileError CrossFileUtilHelper::CopyOrMoveFile( } // anonymous namespace // static +bool FileUtilHelper::PathExists(FileSystemOperationContext* context, + FileSystemFileUtil* file_util, + const FileSystemURL& url) { + base::PlatformFileInfo file_info; + FilePath platform_path; + PlatformFileError error = file_util->GetFileInfo( + context, url, &file_info, &platform_path); + return error == base::PLATFORM_FILE_OK; +} + +// static +bool FileUtilHelper::DirectoryExists(FileSystemOperationContext* context, + FileSystemFileUtil* file_util, + const FileSystemURL& url) { + if (url.path().empty()) + return true; + + base::PlatformFileInfo file_info; + FilePath platform_path; + PlatformFileError error = file_util->GetFileInfo( + context, url, &file_info, &platform_path); + return error == base::PLATFORM_FILE_OK && file_info.is_directory; +} + +// static base::PlatformFileError FileUtilHelper::Copy( FileSystemOperationContext* context, FileSystemFileUtil* src_file_util, @@ -314,7 +341,7 @@ base::PlatformFileError FileUtilHelper::Delete( FileSystemFileUtil* file_util, const FileSystemURL& url, bool recursive) { - if (file_util->DirectoryExists(context, url)) { + if (DirectoryExists(context, file_util, url)) { if (!recursive) return file_util->DeleteSingleDirectory(context, url); else @@ -333,7 +360,7 @@ base::PlatformFileError FileUtilHelper::ReadDirectory( DCHECK(entries); // TODO(kkanetkar): Implement directory read in multiple chunks. - if (!file_util->DirectoryExists(context, url)) + if (!DirectoryExists(context, file_util, url)) return base::PLATFORM_FILE_ERROR_NOT_FOUND; scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> file_enum( |