summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi/file_system_file_util.cc
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-26 11:53:50 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-26 11:53:50 +0000
commit08f8feb39b2c8801dd39a1531fb5958644162e6d (patch)
tree8353404b39167b55fde8adb6c3d0b24b4fccdfee /webkit/fileapi/file_system_file_util.cc
parentf516f4e5d8eff9285234cf18a62108d18229367c (diff)
downloadchromium_src-08f8feb39b2c8801dd39a1531fb5958644162e6d.zip
chromium_src-08f8feb39b2c8801dd39a1531fb5958644162e6d.tar.gz
chromium_src-08f8feb39b2c8801dd39a1531fb5958644162e6d.tar.bz2
Move src/dest info out of FileSystemOperationContext
Current FileSystemOperationContext has both src and dest path file info in it but this is making the code for cross-FileUtil operations way complex. This patch removes src/dest information from FileSystemOperationContext and instead: - introduce new FileSystemPath class, which represents a file path information in a filesystem - replace all the FilePath args in FileSystemFileUtil with FileSystemPath The resulting code still has some ugly part, and if we get rid of cross-FU operations from each FU code eventually we may end up converting FileSystemPath back to FilePath, but I think this change is not far from the way we want to go. BUG=114732, 110121 TEST=existing tests Review URL: http://codereview.chromium.org/9413009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123689 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/file_system_file_util.cc')
-rw-r--r--webkit/fileapi/file_system_file_util.cc277
1 files changed, 131 insertions, 146 deletions
diff --git a/webkit/fileapi/file_system_file_util.cc b/webkit/fileapi/file_system_file_util.cc
index 5daa6a6..9156075 100644
--- a/webkit/fileapi/file_system_file_util.cc
+++ b/webkit/fileapi/file_system_file_util.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -7,6 +7,7 @@
#include <stack>
#include "base/memory/scoped_ptr.h"
+#include "webkit/fileapi/file_system_context.h"
#include "webkit/fileapi/file_system_operation_context.h"
namespace fileapi {
@@ -15,13 +16,14 @@ namespace {
// This assumes that the root exists.
bool ParentExists(FileSystemOperationContext* context,
- FileSystemFileUtil* file_util, const FilePath& file_path) {
- // If file_path is in the root, file_path.DirName() will be ".",
+ const FileSystemPath& path) {
+ // If path is in the root, path.DirName() will be ".",
// since we use paths with no leading '/'.
- FilePath parent = file_path.DirName();
+ FilePath parent = path.internal_path().DirName();
if (parent == FilePath(FILE_PATH_LITERAL(".")))
return true;
- return file_util->DirectoryExists(context, parent);
+ return path.file_util()->DirectoryExists(
+ context, path.WithInternalPath(parent));
}
} // namespace
@@ -38,62 +40,62 @@ FileSystemFileUtil::~FileSystemFileUtil() {
PlatformFileError FileSystemFileUtil::Copy(
FileSystemOperationContext* context,
- const FilePath& src_file_path,
- const FilePath& dest_file_path) {
+ const FileSystemPath& src_path,
+ const FileSystemPath& dest_path) {
PlatformFileError error_code;
error_code =
PerformCommonCheckAndPreparationForMoveAndCopy(
- context, src_file_path, dest_file_path);
+ context, src_path, dest_path);
if (error_code != base::PLATFORM_FILE_OK)
return error_code;
- if (DirectoryExists(context, src_file_path))
- return CopyOrMoveDirectory(context, src_file_path, dest_file_path,
+ if (DirectoryExists(context, src_path))
+ return CopyOrMoveDirectory(context, src_path, dest_path,
true /* copy */);
- return CopyOrMoveFileHelper(context, src_file_path, dest_file_path,
+ return CopyOrMoveFileHelper(context, src_path, dest_path,
true /* copy */);
}
PlatformFileError FileSystemFileUtil::Move(
FileSystemOperationContext* context,
- const FilePath& src_file_path,
- const FilePath& dest_file_path) {
+ const FileSystemPath& src_path,
+ const FileSystemPath& dest_path) {
PlatformFileError error_code;
error_code =
PerformCommonCheckAndPreparationForMoveAndCopy(
- context, src_file_path, dest_file_path);
+ context, src_path, dest_path);
if (error_code != base::PLATFORM_FILE_OK)
return error_code;
// TODO(dmikurube): ReplaceFile if in the same domain and filesystem type.
- if (DirectoryExists(context, src_file_path))
- return CopyOrMoveDirectory(context, src_file_path, dest_file_path,
+ if (DirectoryExists(context, src_path))
+ return CopyOrMoveDirectory(context, src_path, dest_path,
false /* copy */);
- return CopyOrMoveFileHelper(context, src_file_path, dest_file_path,
+ return CopyOrMoveFileHelper(context, src_path, dest_path,
false /* copy */);
}
PlatformFileError FileSystemFileUtil::Delete(
FileSystemOperationContext* context,
- const FilePath& file_path,
+ const FileSystemPath& path,
bool recursive) {
- if (DirectoryExists(context, file_path)) {
+ if (DirectoryExists(context, path)) {
if (!recursive)
- return DeleteSingleDirectory(context, file_path);
+ return DeleteSingleDirectory(context, path);
else
- return DeleteDirectoryRecursive(context, file_path);
+ return DeleteDirectoryRecursive(context, path);
} else {
- return DeleteFile(context, file_path);
+ return DeleteFile(context, path);
}
}
PlatformFileError FileSystemFileUtil::CreateOrOpen(
FileSystemOperationContext* context,
- const FilePath& file_path, int file_flags,
+ const FileSystemPath& path, int file_flags,
PlatformFile* file_handle, bool* created) {
if (underlying_file_util_.get()) {
return underlying_file_util_->CreateOrOpen(
- context, file_path, file_flags, file_handle, created);
+ context, path, file_flags, file_handle, created);
}
NOTREACHED() << "Subclasses must provide implementation if they have no"
<< "underlying_file_util";
@@ -113,10 +115,10 @@ PlatformFileError FileSystemFileUtil::Close(
PlatformFileError FileSystemFileUtil::EnsureFileExists(
FileSystemOperationContext* context,
- const FilePath& file_path,
+ const FileSystemPath& path,
bool* created) {
if (underlying_file_util_.get()) {
- return underlying_file_util_->EnsureFileExists(context, file_path, created);
+ return underlying_file_util_->EnsureFileExists(context, path, created);
}
NOTREACHED() << "Subclasses must provide implementation if they have no"
<< "underlying_file_util";
@@ -125,12 +127,12 @@ PlatformFileError FileSystemFileUtil::EnsureFileExists(
PlatformFileError FileSystemFileUtil::CreateDirectory(
FileSystemOperationContext* context,
- const FilePath& file_path,
+ const FileSystemPath& path,
bool exclusive,
bool recursive) {
if (underlying_file_util_.get()) {
return underlying_file_util_->CreateDirectory(
- context, file_path, exclusive, recursive);
+ context, path, exclusive, recursive);
}
NOTREACHED() << "Subclasses must provide implementation if they have no"
<< "underlying_file_util";
@@ -139,12 +141,12 @@ PlatformFileError FileSystemFileUtil::CreateDirectory(
PlatformFileError FileSystemFileUtil::GetFileInfo(
FileSystemOperationContext* context,
- const FilePath& file_path,
+ const FileSystemPath& path,
base::PlatformFileInfo* file_info,
FilePath* platform_file_path) {
if (underlying_file_util_.get()) {
return underlying_file_util_->GetFileInfo(
- context, file_path, file_info, platform_file_path);
+ context, path, file_info, platform_file_path);
}
NOTREACHED() << "Subclasses must provide implementation if they have no"
<< "underlying_file_util";
@@ -153,10 +155,10 @@ PlatformFileError FileSystemFileUtil::GetFileInfo(
PlatformFileError FileSystemFileUtil::ReadDirectory(
FileSystemOperationContext* context,
- const FilePath& file_path,
+ const FileSystemPath& path,
std::vector<base::FileUtilProxy::Entry>* entries) {
if (underlying_file_util_.get()) {
- return underlying_file_util_->ReadDirectory(context, file_path, entries);
+ return underlying_file_util_->ReadDirectory(context, path, entries);
}
NOTREACHED() << "Subclasses must provide implementation if they have no"
<< "underlying_file_util";
@@ -166,7 +168,7 @@ PlatformFileError FileSystemFileUtil::ReadDirectory(
FileSystemFileUtil::AbstractFileEnumerator*
FileSystemFileUtil::CreateFileEnumerator(
FileSystemOperationContext* context,
- const FilePath& root_path) {
+ const FileSystemPath& root_path) {
if (underlying_file_util_.get()) {
return underlying_file_util_->CreateFileEnumerator(context, root_path);
}
@@ -177,11 +179,11 @@ FileSystemFileUtil::CreateFileEnumerator(
PlatformFileError FileSystemFileUtil::GetLocalFilePath(
FileSystemOperationContext* context,
- const FilePath& virtual_path,
- FilePath* local_path) {
+ const FileSystemPath& file_system_path,
+ FilePath* local_file_path) {
if (underlying_file_util_.get()) {
return underlying_file_util_->GetLocalFilePath(
- context, virtual_path, local_path);
+ context, file_system_path, local_file_path);
}
NOTREACHED() << "Subclasses must provide implementation if they have no"
<< "underlying_file_util";
@@ -190,12 +192,12 @@ PlatformFileError FileSystemFileUtil::GetLocalFilePath(
PlatformFileError FileSystemFileUtil::Touch(
FileSystemOperationContext* context,
- const FilePath& file_path,
+ const FileSystemPath& path,
const base::Time& last_access_time,
const base::Time& last_modified_time) {
if (underlying_file_util_.get()) {
return underlying_file_util_->Touch(
- context, file_path, last_access_time, last_modified_time);
+ context, path, last_access_time, last_modified_time);
}
NOTREACHED() << "Subclasses must provide implementation if they have no"
<< "underlying_file_util";
@@ -204,10 +206,10 @@ PlatformFileError FileSystemFileUtil::Touch(
PlatformFileError FileSystemFileUtil::Truncate(
FileSystemOperationContext* context,
- const FilePath& file_path,
+ const FileSystemPath& path,
int64 length) {
if (underlying_file_util_.get()) {
- return underlying_file_util_->Truncate(context, file_path, length);
+ return underlying_file_util_->Truncate(context, path, length);
}
NOTREACHED() << "Subclasses must provide implementation if they have no"
<< "underlying_file_util";
@@ -217,9 +219,9 @@ PlatformFileError FileSystemFileUtil::Truncate(
bool FileSystemFileUtil::PathExists(
FileSystemOperationContext* context,
- const FilePath& file_path) {
+ const FileSystemPath& path) {
if (underlying_file_util_.get()) {
- return underlying_file_util_->PathExists(context, file_path);
+ return underlying_file_util_->PathExists(context, path);
}
NOTREACHED() << "Subclasses must provide implementation if they have no"
<< "underlying_file_util";
@@ -228,9 +230,9 @@ bool FileSystemFileUtil::PathExists(
bool FileSystemFileUtil::DirectoryExists(
FileSystemOperationContext* context,
- const FilePath& file_path) {
+ const FileSystemPath& path) {
if (underlying_file_util_.get()) {
- return underlying_file_util_->DirectoryExists(context, file_path);
+ return underlying_file_util_->DirectoryExists(context, path);
}
NOTREACHED() << "Subclasses must provide implementation if they have no"
<< "underlying_file_util";
@@ -239,9 +241,9 @@ bool FileSystemFileUtil::DirectoryExists(
bool FileSystemFileUtil::IsDirectoryEmpty(
FileSystemOperationContext* context,
- const FilePath& file_path) {
+ const FileSystemPath& path) {
if (underlying_file_util_.get()) {
- return underlying_file_util_->IsDirectoryEmpty(context, file_path);
+ return underlying_file_util_->IsDirectoryEmpty(context, path);
}
NOTREACHED() << "Subclasses must provide implementation if they have no"
<< "underlying_file_util";
@@ -250,12 +252,12 @@ bool FileSystemFileUtil::IsDirectoryEmpty(
PlatformFileError FileSystemFileUtil::CopyOrMoveFile(
FileSystemOperationContext* context,
- const FilePath& src_file_path,
- const FilePath& dest_file_path,
+ const FileSystemPath& src_path,
+ const FileSystemPath& dest_path,
bool copy) {
if (underlying_file_util_.get()) {
return underlying_file_util_->CopyOrMoveFile(
- context, src_file_path, dest_file_path, copy);
+ context, src_path, dest_path, copy);
}
NOTREACHED() << "Subclasses must provide implementation if they have no"
<< "underlying_file_util";
@@ -264,11 +266,11 @@ PlatformFileError FileSystemFileUtil::CopyOrMoveFile(
PlatformFileError FileSystemFileUtil::CopyInForeignFile(
FileSystemOperationContext* context,
- const FilePath& src_file_path,
- const FilePath& dest_file_path) {
+ const FileSystemPath& underlying_src_path,
+ const FileSystemPath& dest_path) {
if (underlying_file_util_.get()) {
return underlying_file_util_->CopyInForeignFile(
- context, src_file_path, dest_file_path);
+ context, underlying_src_path, dest_path);
}
NOTREACHED() << "Subclasses must provide implementation if they have no"
<< "underlying_file_util";
@@ -277,9 +279,9 @@ PlatformFileError FileSystemFileUtil::CopyInForeignFile(
PlatformFileError FileSystemFileUtil::DeleteFile(
FileSystemOperationContext* context,
- const FilePath& file_path) {
+ const FileSystemPath& path) {
if (underlying_file_util_.get()) {
- return underlying_file_util_->DeleteFile(context, file_path);
+ return underlying_file_util_->DeleteFile(context, path);
}
NOTREACHED() << "Subclasses must provide implementation if they have no"
<< "underlying_file_util";
@@ -288,9 +290,9 @@ PlatformFileError FileSystemFileUtil::DeleteFile(
PlatformFileError FileSystemFileUtil::DeleteSingleDirectory(
FileSystemOperationContext* context,
- const FilePath& file_path) {
+ const FileSystemPath& path) {
if (underlying_file_util_.get()) {
- return underlying_file_util_->DeleteSingleDirectory(context, file_path);
+ return underlying_file_util_->DeleteSingleDirectory(context, path);
}
NOTREACHED() << "Subclasses must provide implementation if they have no"
<< "underlying_file_util";
@@ -300,59 +302,47 @@ PlatformFileError FileSystemFileUtil::DeleteSingleDirectory(
PlatformFileError
FileSystemFileUtil::PerformCommonCheckAndPreparationForMoveAndCopy(
FileSystemOperationContext* context,
- const FilePath& src_file_path,
- const FilePath& dest_file_path) {
- bool same_file_system =
- (context->src_origin_url() == context->dest_origin_url()) &&
- (context->src_type() == context->dest_type());
- FileSystemFileUtil* dest_util = context->dest_file_util();
- DCHECK(dest_util);
- scoped_ptr<FileSystemOperationContext> local_dest_context;
- FileSystemOperationContext* dest_context = NULL;
- if (same_file_system) {
- dest_context = context;
- DCHECK(context->src_file_util() == context->dest_file_util());
- } else {
- local_dest_context.reset(context->CreateInheritedContextForDest());
- // All the single-path virtual FSFU methods expect the context information
- // to be in the src_* variables, not the dest_* variables, so we have to
- // make a new context if we want to call them on the dest_file_path.
- dest_context = local_dest_context.get();
- }
-
+ const FileSystemPath& src_path,
+ const FileSystemPath& dest_path) {
// Exits earlier if the source path does not exist.
- if (!PathExists(context, src_file_path))
+ if (!PathExists(context, src_path))
return base::PLATFORM_FILE_ERROR_NOT_FOUND;
- // The parent of the |dest_file_path| does not exist.
- if (!ParentExists(dest_context, dest_util, dest_file_path))
+ // It is an error to copy/move an entry into the same path.
+ if (src_path == dest_path)
+ return base::PLATFORM_FILE_ERROR_EXISTS;
+
+ bool same_file_system =
+ (src_path.origin() == dest_path.origin()) &&
+ (src_path.type() == dest_path.type());
+ FileSystemFileUtil* dest_util = dest_path.file_util();
+ DCHECK(dest_util);
+
+ // The parent of the |dest_path| does not exist.
+ if (!ParentExists(context, dest_path))
return base::PLATFORM_FILE_ERROR_NOT_FOUND;
// It is an error to try to copy/move an entry into its child.
- if (same_file_system && src_file_path.IsParent(dest_file_path))
+ if (same_file_system && src_path.IsParent(dest_path))
return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
- // Now it is ok to return if the |dest_file_path| does not exist.
- if (!dest_util->PathExists(dest_context, dest_file_path))
+ // Now it is ok to return if the |dest_path| does not exist.
+ if (!dest_util->PathExists(context, dest_path))
return base::PLATFORM_FILE_OK;
- // |src_file_path| exists and is a directory.
- // |dest_file_path| exists and is a file.
- bool src_is_directory = DirectoryExists(context, src_file_path);
+ // |src_path| exists and is a directory.
+ // |dest_path| exists and is a file.
+ bool src_is_directory = DirectoryExists(context, src_path);
bool dest_is_directory =
- dest_util->DirectoryExists(dest_context, dest_file_path);
+ dest_util->DirectoryExists(context, dest_path);
if (src_is_directory && !dest_is_directory)
return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
- // |src_file_path| exists and is a file.
- // |dest_file_path| exists and is a directory.
+ // |src_path| exists and is a file.
+ // |dest_path| exists and is a directory.
if (!src_is_directory && dest_is_directory)
return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
- // It is an error to copy/move an entry into the same path.
- if (same_file_system && (src_file_path.value() == dest_file_path.value()))
- return base::PLATFORM_FILE_ERROR_EXISTS;
-
if (dest_is_directory) {
// It is an error to copy/move an entry to a non-empty directory.
// Otherwise the copy/move attempt must overwrite the destination, but
@@ -360,72 +350,65 @@ FileSystemFileUtil::PerformCommonCheckAndPreparationForMoveAndCopy(
// on all platforms, so we delete the destination directory here.
// TODO(kinuko): may be better to change the file_util::{Copy,Move}.
if (base::PLATFORM_FILE_OK !=
- dest_util->Delete(dest_context, dest_file_path,
- false /* recursive */)) {
- if (!dest_util->IsDirectoryEmpty(dest_context, dest_file_path))
+ dest_util->Delete(context, dest_path, false /* recursive */)) {
+ if (!dest_util->IsDirectoryEmpty(context, dest_path))
return base::PLATFORM_FILE_ERROR_NOT_EMPTY;
return base::PLATFORM_FILE_ERROR_FAILED;
}
- // Reflect changes in usage back to the original context.
- if (!same_file_system)
- context->set_allowed_bytes_growth(dest_context->allowed_bytes_growth());
}
return base::PLATFORM_FILE_OK;
}
PlatformFileError FileSystemFileUtil::CopyOrMoveDirectory(
FileSystemOperationContext* context,
- const FilePath& src_file_path,
- const FilePath& dest_file_path,
+ const FileSystemPath& src_path,
+ const FileSystemPath& dest_path,
bool copy) {
- FileSystemFileUtil* dest_util = context->dest_file_util();
- // All the single-path virtual FSFU methods expect the context information to
- // be in the src_* variables, not the dest_* variables, so we have to make a
- // new context if we want to call them on the dest_file_path.
- scoped_ptr<FileSystemOperationContext> dest_context(
- context->CreateInheritedContextForDest());
+ FileSystemFileUtil* dest_util = dest_path.file_util();
// Re-check PerformCommonCheckAndPreparationForMoveAndCopy() by DCHECK.
- DCHECK(DirectoryExists(context, src_file_path));
- DCHECK(ParentExists(dest_context.get(), dest_util, dest_file_path));
- DCHECK(!dest_util->PathExists(dest_context.get(), dest_file_path));
- if ((context->src_origin_url() == context->dest_origin_url()) &&
- (context->src_type() == context->dest_type()))
- DCHECK(!src_file_path.IsParent(dest_file_path));
-
- if (!dest_util->DirectoryExists(dest_context.get(), dest_file_path)) {
- PlatformFileError error = dest_util->CreateDirectory(dest_context.get(),
- dest_file_path, false, false);
+ DCHECK(DirectoryExists(context, src_path));
+ DCHECK(ParentExists(context, dest_path));
+ DCHECK(!dest_util->PathExists(context, dest_path));
+ if ((src_path.origin() == dest_path.origin()) &&
+ (src_path.type() == dest_path.type()))
+ DCHECK(!src_path.IsParent(dest_path));
+
+ if (!dest_util->DirectoryExists(context, dest_path)) {
+ PlatformFileError error = dest_util->CreateDirectory(
+ context, dest_path, false, false);
if (error != base::PLATFORM_FILE_OK)
return error;
- // Reflect changes in usage back to the original context.
- context->set_allowed_bytes_growth(dest_context->allowed_bytes_growth());
}
scoped_ptr<AbstractFileEnumerator> file_enum(
- CreateFileEnumerator(context, src_file_path));
+ CreateFileEnumerator(context, src_path));
FilePath src_file_path_each;
while (!(src_file_path_each = file_enum->Next()).empty()) {
- FilePath dest_file_path_each(dest_file_path);
- src_file_path.AppendRelativePath(src_file_path_each, &dest_file_path_each);
+ FilePath dest_file_path_each(dest_path.internal_path());
+ src_path.internal_path().AppendRelativePath(
+ src_file_path_each, &dest_file_path_each);
if (file_enum->IsDirectory()) {
- PlatformFileError error = dest_util->CreateDirectory(dest_context.get(),
- dest_file_path_each, false, false);
+ PlatformFileError error = dest_util->CreateDirectory(
+ context,
+ dest_path.WithInternalPath(dest_file_path_each),
+ false, false);
if (error != base::PLATFORM_FILE_OK)
return error;
- // Reflect changes in usage back to the original context.
- context->set_allowed_bytes_growth(dest_context->allowed_bytes_growth());
} else {
PlatformFileError error = CopyOrMoveFileHelper(
- context, src_file_path_each, dest_file_path_each, copy);
+ context,
+ src_path.WithInternalPath(src_file_path_each),
+ dest_path.WithInternalPath(dest_file_path_each),
+ copy);
if (error != base::PLATFORM_FILE_OK)
return error;
}
}
if (!copy) {
- PlatformFileError error = Delete(context, src_file_path, true);
+ PlatformFileError error = Delete(context, src_path, true);
if (error != base::PLATFORM_FILE_OK)
return error;
}
@@ -435,45 +418,46 @@ PlatformFileError FileSystemFileUtil::CopyOrMoveDirectory(
PlatformFileError FileSystemFileUtil::CopyOrMoveFileHelper(
FileSystemOperationContext* context,
- const FilePath& src_file_path,
- const FilePath& dest_file_path,
+ const FileSystemPath& src_path,
+ const FileSystemPath& dest_path,
bool copy) {
// CopyOrMoveFile here is the virtual overridden member function.
- if ((context->src_origin_url() == context->dest_origin_url()) &&
- (context->src_type() == context->dest_type())) {
- DCHECK(context->src_file_util() == context->dest_file_util());
- return CopyOrMoveFile(context, src_file_path, dest_file_path, copy);
+ if ((src_path.origin() == dest_path.origin()) &&
+ (src_path.type() == dest_path.type())) {
+ DCHECK(src_path.file_util() == dest_path.file_util());
+ return CopyOrMoveFile(context, src_path, dest_path, copy);
}
+
base::PlatformFileInfo file_info;
- FilePath platform_file_path;
+ FilePath underlying_file_path;
PlatformFileError error_code;
- error_code =
- GetFileInfo(context, src_file_path, &file_info, &platform_file_path);
+ error_code = src_path.file_util()->GetFileInfo(
+ context, src_path, &file_info, &underlying_file_path);
if (error_code != base::PLATFORM_FILE_OK)
return error_code;
- DCHECK(context->dest_file_util());
- error_code = context->dest_file_util()->CopyInForeignFile(
- context, platform_file_path, dest_file_path);
+ DCHECK(dest_path.file_util());
+ error_code = dest_path.file_util()->CopyInForeignFile(
+ context, src_path.WithInternalPath(underlying_file_path), dest_path);
if (copy || error_code != base::PLATFORM_FILE_OK)
return error_code;
- return DeleteFile(context, src_file_path);
+ return src_path.file_util()->DeleteFile(context, src_path);
}
PlatformFileError FileSystemFileUtil::DeleteDirectoryRecursive(
FileSystemOperationContext* context,
- const FilePath& file_path) {
+ const FileSystemPath& path) {
scoped_ptr<AbstractFileEnumerator> file_enum(
- CreateFileEnumerator(context, file_path));
+ CreateFileEnumerator(context, path));
FilePath file_path_each;
-
std::stack<FilePath> directories;
while (!(file_path_each = file_enum->Next()).empty()) {
if (file_enum->IsDirectory()) {
directories.push(file_path_each);
} else {
// DeleteFile here is the virtual overridden member function.
- PlatformFileError error = DeleteFile(context, file_path_each);
+ PlatformFileError error = DeleteFile(
+ context, path.WithInternalPath(file_path_each));
if (error == base::PLATFORM_FILE_ERROR_NOT_FOUND)
return base::PLATFORM_FILE_ERROR_FAILED;
else if (error != base::PLATFORM_FILE_OK)
@@ -482,14 +466,15 @@ PlatformFileError FileSystemFileUtil::DeleteDirectoryRecursive(
}
while (!directories.empty()) {
- PlatformFileError error = DeleteSingleDirectory(context, directories.top());
+ PlatformFileError error = DeleteSingleDirectory(
+ context, path.WithInternalPath(directories.top()));
if (error == base::PLATFORM_FILE_ERROR_NOT_FOUND)
return base::PLATFORM_FILE_ERROR_FAILED;
else if (error != base::PLATFORM_FILE_OK)
return error;
directories.pop();
}
- return DeleteSingleDirectory(context, file_path);
+ return DeleteSingleDirectory(context, path);
}
} // namespace fileapi