summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi/file_system_file_util.h
diff options
context:
space:
mode:
authordmikurube@chromium.org <dmikurube@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-13 09:49:21 +0000
committerdmikurube@chromium.org <dmikurube@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-13 09:49:21 +0000
commitb4bd05478c5e4475d4cc91d05825094f931799e2 (patch)
tree057a80d03ac51a820142c57b14d0f4a851e1c23c /webkit/fileapi/file_system_file_util.h
parent64822d64607a6247f796196dd18af20c9da7745f (diff)
downloadchromium_src-b4bd05478c5e4475d4cc91d05825094f931799e2.zip
chromium_src-b4bd05478c5e4475d4cc91d05825094f931799e2.tar.gz
chromium_src-b4bd05478c5e4475d4cc91d05825094f931799e2.tar.bz2
Extract a recursive copy function as a shared and non-virtual function.
This extraction is required to stack FileUtil layers without duplicated code of recursive copy. No tests because it doesn't change any behavior. BUG=none TEST=none Review URL: http://codereview.chromium.org/6772005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81388 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/file_system_file_util.h')
-rw-r--r--webkit/fileapi/file_system_file_util.h46
1 files changed, 42 insertions, 4 deletions
diff --git a/webkit/fileapi/file_system_file_util.h b/webkit/fileapi/file_system_file_util.h
index a208ae4..9d3eb26 100644
--- a/webkit/fileapi/file_system_file_util.h
+++ b/webkit/fileapi/file_system_file_util.h
@@ -64,7 +64,7 @@ class FileSystemFileUtil {
FileSystemOperationContext* context,
const FilePath& file_path, bool* created);
- // Retrieves the information about a file. It is invalid to pass NULL for the
+ // Retrieves the information about a file. It is invalid to pass NULL for the
// callback.
virtual PlatformFileError GetFileInfo(
FileSystemOperationContext* context,
@@ -85,19 +85,24 @@ class FileSystemFileUtil {
bool exclusive,
bool recursive);
+ // TODO(dmikurube): Make this method non-virtual if it's possible.
+ // It conflicts with LocalFileSystemFileUtil for now.
+ //
// Copies a file or a directory from |src_file_path| to |dest_file_path|
// Error cases:
- // If destination file doesn't exist or destination's parent
- // doesn't exists.
+ // If destination's parent doesn't exist.
// If source dir exists but destination path is an existing file.
// If source file exists but destination path is an existing directory.
// If source is a parent of destination.
- // If source doesn't exists.
+ // If source doesn't exist.
virtual PlatformFileError Copy(
FileSystemOperationContext* context,
const FilePath& src_file_path,
const FilePath& dest_file_path);
+ // TODO(dmikurube): Make this method non-virtual if it's possible.
+ // It conflicts with LocalFileSystemFileUtil for now.
+ //
// Moves a file or a directory from src_file_path to dest_file_path.
// Error cases are similar to Copy method's error cases.
virtual PlatformFileError Move(
@@ -127,12 +132,22 @@ class FileSystemFileUtil {
const FilePath& path,
int64 length);
+ // It will be implemented by each subclass such as FileSystemFileEnumerator.
+ class AbstractFileEnumerator {
+ public:
+ // Returns an empty string if there are no more results.
+ virtual FilePath Next() = 0;
+
+ virtual bool IsDirectory() = 0;
+ };
+
protected:
FileSystemFileUtil() { }
// This also removes the destination directory if it's non-empty and all
// other checks are passed (so that the copy/move correctly overwrites the
// destination).
+ // This method is non-virtual, not to be overridden.
PlatformFileError PerformCommonCheckAndPreparationForMoveAndCopy(
FileSystemOperationContext* unused,
const FilePath& src_file_path,
@@ -150,6 +165,29 @@ class FileSystemFileUtil {
FileSystemOperationContext* unused,
const FilePath& file_path);
+ // Copies or moves a single file.
+ virtual PlatformFileError CopyOrMoveFile(
+ FileSystemOperationContext* context,
+ const FilePath& src_file_path,
+ const FilePath& dest_file_path,
+ bool copy);
+
+ // Performs recursive copy by calling CopyOrMoveFile for individual files.
+ // Operations for recursive traversal are encapsulated in this method.
+ // It assumes src_file_path and dest_file_path have passed
+ // PerformCommonCheckAndPreparationForMoveAndCopy().
+ // This method is non-virtual, not to be overridden.
+ PlatformFileError CopyDirectory(
+ FileSystemOperationContext* context,
+ const FilePath& src_file_path,
+ const FilePath& dest_file_path);
+
+ // Returns a pointer to a new instance of AbstractFileEnumerator which is
+ // implemented for each FileUtil subclass. The instance needs to be freed
+ // by the caller.
+ virtual AbstractFileEnumerator* CreateFileEnumerator(
+ const FilePath& root_path);
+
friend struct DefaultSingletonTraits<FileSystemFileUtil>;
DISALLOW_COPY_AND_ASSIGN(FileSystemFileUtil);
};