Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Unified Diff: webkit/fileapi/native_file_util.cc

Issue 12051010: (For-try) Divide recursive Copy/Move into multiple async tasks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test fix Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/fileapi/native_file_util.cc
diff --git a/webkit/fileapi/native_file_util.cc b/webkit/fileapi/native_file_util.cc
index c6bc50ba041cc29a1246a0dd44766b387d5c8952..7ee3b04b861354feb8fa4129f2752f20079aa9a1 100644
--- a/webkit/fileapi/native_file_util.cc
+++ b/webkit/fileapi/native_file_util.cc
@@ -202,20 +202,35 @@ bool NativeFileUtil::DirectoryExists(const FilePath& path) {
return file_util::DirectoryExists(path);
}
-bool NativeFileUtil::IsDirectoryEmpty(const FilePath& path) {
- return file_util::IsDirectoryEmpty(path);
-}
-
PlatformFileError NativeFileUtil::CopyOrMoveFile(
const FilePath& src_path,
const FilePath& dest_path,
bool copy) {
+ base::PlatformFileInfo info;
+ base::PlatformFileError error = NativeFileUtil::GetFileInfo(src_path, &info);
+ if (error != base::PLATFORM_FILE_OK)
+ return error;
+ if (info.is_directory)
+ return base::PLATFORM_FILE_ERROR_NOT_A_FILE;
+
+ error = NativeFileUtil::GetFileInfo(dest_path, &info);
+ if (error != base::PLATFORM_FILE_OK &&
+ error != base::PLATFORM_FILE_ERROR_NOT_FOUND)
+ return error;
+ if (info.is_directory)
+ return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
+ if (error == base::PLATFORM_FILE_ERROR_NOT_FOUND) {
+ error = NativeFileUtil::GetFileInfo(dest_path.DirName(), &info);
+ if (error != base::PLATFORM_FILE_OK)
+ return error;
+ if (!info.is_directory)
+ return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ }
+
if (copy) {
- if (file_util::CopyFile(src_path,
- dest_path))
+ if (file_util::CopyFile(src_path, dest_path))
return base::PLATFORM_FILE_OK;
} else {
- DCHECK(!file_util::DirectoryExists(src_path));
if (file_util::Move(src_path, dest_path))
return base::PLATFORM_FILE_OK;
}
@@ -232,17 +247,13 @@ PlatformFileError NativeFileUtil::DeleteFile(const FilePath& path) {
return base::PLATFORM_FILE_OK;
}
-PlatformFileError NativeFileUtil::DeleteSingleDirectory(const FilePath& path) {
+PlatformFileError NativeFileUtil::DeleteDirectory(const FilePath& path) {
if (!file_util::PathExists(path))
return base::PLATFORM_FILE_ERROR_NOT_FOUND;
- if (!file_util::DirectoryExists(path)) {
- // TODO(dmikurube): Check if this error code is appropriate.
+ if (!file_util::DirectoryExists(path))
return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY;
- }
- if (!file_util::IsDirectoryEmpty(path)) {
- // TODO(dmikurube): Check if this error code is appropriate.
+ if (!file_util::IsDirectoryEmpty(path))
return base::PLATFORM_FILE_ERROR_NOT_EMPTY;
- }
if (!file_util::Delete(path, false))
return base::PLATFORM_FILE_ERROR_FAILED;
return base::PLATFORM_FILE_OK;

Powered by Google App Engine
This is Rietveld 408576698