| Index: webkit/fileapi/file_system_file_util.cc
|
| diff --git a/webkit/fileapi/file_system_file_util.cc b/webkit/fileapi/file_system_file_util.cc
|
| index 467c38e0e4ced6cf32034603a4ebc7d758364560..5daa6a6cd53e1fed64054ee3402a2c2b6e13b003 100644
|
| --- a/webkit/fileapi/file_system_file_util.cc
|
| +++ b/webkit/fileapi/file_system_file_util.cc
|
| @@ -5,9 +5,7 @@
|
| #include "webkit/fileapi/file_system_file_util.h"
|
|
|
| #include <stack>
|
| -#include <vector>
|
|
|
| -#include "base/file_util_proxy.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "webkit/fileapi/file_system_operation_context.h"
|
|
|
| @@ -28,133 +26,14 @@ bool ParentExists(FileSystemOperationContext* context,
|
|
|
| } // namespace
|
|
|
| -PlatformFileError FileSystemFileUtil::CreateOrOpen(
|
| - FileSystemOperationContext* unused,
|
| - const FilePath& file_path, int file_flags,
|
| - PlatformFile* file_handle, bool* created) {
|
| - if (!file_util::DirectoryExists(file_path.DirName())) {
|
| - // If its parent does not exist, should return NOT_FOUND error.
|
| - return base::PLATFORM_FILE_ERROR_NOT_FOUND;
|
| - }
|
| - PlatformFileError error_code = base::PLATFORM_FILE_OK;
|
| - *file_handle = base::CreatePlatformFile(file_path, file_flags,
|
| - created, &error_code);
|
| - return error_code;
|
| -}
|
| -
|
| -PlatformFileError FileSystemFileUtil::Close(
|
| - FileSystemOperationContext* unused,
|
| - PlatformFile file_handle) {
|
| - if (!base::ClosePlatformFile(file_handle))
|
| - return base::PLATFORM_FILE_ERROR_FAILED;
|
| - return base::PLATFORM_FILE_OK;
|
| -}
|
| -
|
| -PlatformFileError FileSystemFileUtil::EnsureFileExists(
|
| - FileSystemOperationContext* unused,
|
| - const FilePath& file_path,
|
| - bool* created) {
|
| - if (!file_util::DirectoryExists(file_path.DirName()))
|
| - // If its parent does not exist, should return NOT_FOUND error.
|
| - return base::PLATFORM_FILE_ERROR_NOT_FOUND;
|
| - PlatformFileError error_code = base::PLATFORM_FILE_OK;
|
| - // Tries to create the |file_path| exclusively. This should fail
|
| - // with base::PLATFORM_FILE_ERROR_EXISTS if the path already exists.
|
| - PlatformFile handle = base::CreatePlatformFile(
|
| - file_path,
|
| - base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_READ,
|
| - created, &error_code);
|
| - if (error_code == base::PLATFORM_FILE_ERROR_EXISTS) {
|
| - // Make sure created_ is false.
|
| - if (created)
|
| - *created = false;
|
| - error_code = base::PLATFORM_FILE_OK;
|
| - }
|
| - if (handle != base::kInvalidPlatformFileValue)
|
| - base::ClosePlatformFile(handle);
|
| - return error_code;
|
| -}
|
| -
|
| -PlatformFileError FileSystemFileUtil::GetLocalFilePath(
|
| - FileSystemOperationContext* context,
|
| - const FilePath& virtual_path,
|
| - FilePath* local_path) {
|
| - *local_path = virtual_path;
|
| - return base::PLATFORM_FILE_OK;
|
| -}
|
| -
|
| -PlatformFileError FileSystemFileUtil::GetFileInfo(
|
| - FileSystemOperationContext* unused,
|
| - const FilePath& file_path,
|
| - base::PlatformFileInfo* file_info,
|
| - FilePath* platform_file_path) {
|
| - if (!file_util::PathExists(file_path))
|
| - return base::PLATFORM_FILE_ERROR_NOT_FOUND;
|
| - // TODO(rkc): Fix this hack once we have refactored file_util to handle
|
| - // symlinks correctly.
|
| - // http://code.google.com/p/chromium-os/issues/detail?id=15948
|
| - if (file_util::IsLink(file_path))
|
| - return base::PLATFORM_FILE_ERROR_NOT_FOUND;
|
| - if (!file_util::GetFileInfo(file_path, file_info))
|
| - return base::PLATFORM_FILE_ERROR_FAILED;
|
| - *platform_file_path = file_path;
|
| - return base::PLATFORM_FILE_OK;
|
| +FileSystemFileUtil::FileSystemFileUtil() {
|
| }
|
|
|
| -PlatformFileError FileSystemFileUtil::ReadDirectory(
|
| - FileSystemOperationContext* unused,
|
| - const FilePath& file_path,
|
| - std::vector<base::FileUtilProxy::Entry>* entries) {
|
| - // TODO(kkanetkar): Implement directory read in multiple chunks.
|
| - if (!file_util::DirectoryExists(file_path))
|
| - return base::PLATFORM_FILE_ERROR_NOT_FOUND;
|
| -
|
| - file_util::FileEnumerator file_enum(
|
| - file_path, false, static_cast<file_util::FileEnumerator::FileType>(
|
| - file_util::FileEnumerator::FILES |
|
| - file_util::FileEnumerator::DIRECTORIES));
|
| - FilePath current;
|
| - while (!(current = file_enum.Next()).empty()) {
|
| - base::FileUtilProxy::Entry entry;
|
| - file_util::FileEnumerator::FindInfo info;
|
| - file_enum.GetFindInfo(&info);
|
| - entry.is_directory = file_enum.IsDirectory(info);
|
| - // This will just give the entry's name instead of entire path
|
| - // if we use current.value().
|
| - entry.name = file_util::FileEnumerator::GetFilename(info).value();
|
| - entry.size = file_util::FileEnumerator::GetFilesize(info);
|
| - entry.last_modified_time =
|
| - file_util::FileEnumerator::GetLastModifiedTime(info);
|
| - // TODO(rkc): Fix this also once we've refactored file_util
|
| - // http://code.google.com/p/chromium-os/issues/detail?id=15948
|
| - // This currently just prevents a file from showing up at all
|
| - // if it's a link, hence preventing arbitary 'read' exploits.
|
| - if (!file_util::IsLink(file_path.Append(entry.name)))
|
| - entries->push_back(entry);
|
| - }
|
| - return base::PLATFORM_FILE_OK;
|
| +FileSystemFileUtil::FileSystemFileUtil(FileSystemFileUtil* underlying_file_util)
|
| + : underlying_file_util_(underlying_file_util) {
|
| }
|
|
|
| -PlatformFileError FileSystemFileUtil::CreateDirectory(
|
| - FileSystemOperationContext* unused,
|
| - const FilePath& file_path,
|
| - bool exclusive,
|
| - bool recursive) {
|
| - // If parent dir of file doesn't exist.
|
| - if (!recursive && !file_util::PathExists(file_path.DirName()))
|
| - return base::PLATFORM_FILE_ERROR_NOT_FOUND;
|
| -
|
| - bool path_exists = file_util::PathExists(file_path);
|
| - if (exclusive && path_exists)
|
| - return base::PLATFORM_FILE_ERROR_EXISTS;
|
| -
|
| - // If file exists at the path.
|
| - if (path_exists && !file_util::DirectoryExists(file_path))
|
| - return base::PLATFORM_FILE_ERROR_EXISTS;
|
| -
|
| - if (!file_util::CreateDirectory(file_path))
|
| - return base::PLATFORM_FILE_ERROR_FAILED;
|
| - return base::PLATFORM_FILE_OK;
|
| +FileSystemFileUtil::~FileSystemFileUtil() {
|
| }
|
|
|
| PlatformFileError FileSystemFileUtil::Copy(
|
| @@ -208,36 +87,214 @@ PlatformFileError FileSystemFileUtil::Delete(
|
| }
|
| }
|
|
|
| +PlatformFileError FileSystemFileUtil::CreateOrOpen(
|
| + FileSystemOperationContext* context,
|
| + const FilePath& file_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);
|
| + }
|
| + NOTREACHED() << "Subclasses must provide implementation if they have no"
|
| + << "underlying_file_util";
|
| + return base::PLATFORM_FILE_ERROR_FAILED;
|
| +}
|
| +
|
| +PlatformFileError FileSystemFileUtil::Close(
|
| + FileSystemOperationContext* context,
|
| + PlatformFile file_handle) {
|
| + if (underlying_file_util_.get()) {
|
| + return underlying_file_util_->Close(context, file_handle);
|
| + }
|
| + NOTREACHED() << "Subclasses must provide implementation if they have no"
|
| + << "underlying_file_util";
|
| + return base::PLATFORM_FILE_ERROR_FAILED;
|
| +}
|
| +
|
| +PlatformFileError FileSystemFileUtil::EnsureFileExists(
|
| + FileSystemOperationContext* context,
|
| + const FilePath& file_path,
|
| + bool* created) {
|
| + if (underlying_file_util_.get()) {
|
| + return underlying_file_util_->EnsureFileExists(context, file_path, created);
|
| + }
|
| + NOTREACHED() << "Subclasses must provide implementation if they have no"
|
| + << "underlying_file_util";
|
| + return base::PLATFORM_FILE_ERROR_FAILED;
|
| +}
|
| +
|
| +PlatformFileError FileSystemFileUtil::CreateDirectory(
|
| + FileSystemOperationContext* context,
|
| + const FilePath& file_path,
|
| + bool exclusive,
|
| + bool recursive) {
|
| + if (underlying_file_util_.get()) {
|
| + return underlying_file_util_->CreateDirectory(
|
| + context, file_path, exclusive, recursive);
|
| + }
|
| + NOTREACHED() << "Subclasses must provide implementation if they have no"
|
| + << "underlying_file_util";
|
| + return base::PLATFORM_FILE_ERROR_FAILED;
|
| +}
|
| +
|
| +PlatformFileError FileSystemFileUtil::GetFileInfo(
|
| + FileSystemOperationContext* context,
|
| + const FilePath& file_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);
|
| + }
|
| + NOTREACHED() << "Subclasses must provide implementation if they have no"
|
| + << "underlying_file_util";
|
| + return base::PLATFORM_FILE_ERROR_FAILED;
|
| +}
|
| +
|
| +PlatformFileError FileSystemFileUtil::ReadDirectory(
|
| + FileSystemOperationContext* context,
|
| + const FilePath& file_path,
|
| + std::vector<base::FileUtilProxy::Entry>* entries) {
|
| + if (underlying_file_util_.get()) {
|
| + return underlying_file_util_->ReadDirectory(context, file_path, entries);
|
| + }
|
| + NOTREACHED() << "Subclasses must provide implementation if they have no"
|
| + << "underlying_file_util";
|
| + return base::PLATFORM_FILE_ERROR_FAILED;
|
| +}
|
| +
|
| +FileSystemFileUtil::AbstractFileEnumerator*
|
| +FileSystemFileUtil::CreateFileEnumerator(
|
| + FileSystemOperationContext* context,
|
| + const FilePath& root_path) {
|
| + if (underlying_file_util_.get()) {
|
| + return underlying_file_util_->CreateFileEnumerator(context, root_path);
|
| + }
|
| + NOTREACHED() << "Subclasses must provide implementation if they have no"
|
| + << "underlying_file_util";
|
| + return NULL;
|
| +}
|
| +
|
| +PlatformFileError FileSystemFileUtil::GetLocalFilePath(
|
| + FileSystemOperationContext* context,
|
| + const FilePath& virtual_path,
|
| + FilePath* local_path) {
|
| + if (underlying_file_util_.get()) {
|
| + return underlying_file_util_->GetLocalFilePath(
|
| + context, virtual_path, local_path);
|
| + }
|
| + NOTREACHED() << "Subclasses must provide implementation if they have no"
|
| + << "underlying_file_util";
|
| + return base::PLATFORM_FILE_ERROR_FAILED;
|
| +}
|
| +
|
| PlatformFileError FileSystemFileUtil::Touch(
|
| - FileSystemOperationContext* unused,
|
| + FileSystemOperationContext* context,
|
| const FilePath& file_path,
|
| const base::Time& last_access_time,
|
| const base::Time& last_modified_time) {
|
| - if (!file_util::TouchFile(
|
| - file_path, last_access_time, last_modified_time))
|
| - return base::PLATFORM_FILE_ERROR_FAILED;
|
| - return base::PLATFORM_FILE_OK;
|
| + if (underlying_file_util_.get()) {
|
| + return underlying_file_util_->Touch(
|
| + context, file_path, last_access_time, last_modified_time);
|
| + }
|
| + NOTREACHED() << "Subclasses must provide implementation if they have no"
|
| + << "underlying_file_util";
|
| + return base::PLATFORM_FILE_ERROR_FAILED;
|
| }
|
|
|
| PlatformFileError FileSystemFileUtil::Truncate(
|
| - FileSystemOperationContext* unused,
|
| + FileSystemOperationContext* context,
|
| const FilePath& file_path,
|
| int64 length) {
|
| - PlatformFileError error_code(base::PLATFORM_FILE_ERROR_FAILED);
|
| - PlatformFile file =
|
| - base::CreatePlatformFile(
|
| - file_path,
|
| - base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE,
|
| - NULL,
|
| - &error_code);
|
| - if (error_code != base::PLATFORM_FILE_OK) {
|
| - return error_code;
|
| + if (underlying_file_util_.get()) {
|
| + return underlying_file_util_->Truncate(context, file_path, length);
|
| + }
|
| + NOTREACHED() << "Subclasses must provide implementation if they have no"
|
| + << "underlying_file_util";
|
| + return base::PLATFORM_FILE_ERROR_FAILED;
|
| +}
|
| +
|
| +
|
| +bool FileSystemFileUtil::PathExists(
|
| + FileSystemOperationContext* context,
|
| + const FilePath& file_path) {
|
| + if (underlying_file_util_.get()) {
|
| + return underlying_file_util_->PathExists(context, file_path);
|
| + }
|
| + NOTREACHED() << "Subclasses must provide implementation if they have no"
|
| + << "underlying_file_util";
|
| + return false;
|
| +}
|
| +
|
| +bool FileSystemFileUtil::DirectoryExists(
|
| + FileSystemOperationContext* context,
|
| + const FilePath& file_path) {
|
| + if (underlying_file_util_.get()) {
|
| + return underlying_file_util_->DirectoryExists(context, file_path);
|
| + }
|
| + NOTREACHED() << "Subclasses must provide implementation if they have no"
|
| + << "underlying_file_util";
|
| + return false;
|
| +}
|
| +
|
| +bool FileSystemFileUtil::IsDirectoryEmpty(
|
| + FileSystemOperationContext* context,
|
| + const FilePath& file_path) {
|
| + if (underlying_file_util_.get()) {
|
| + return underlying_file_util_->IsDirectoryEmpty(context, file_path);
|
| + }
|
| + NOTREACHED() << "Subclasses must provide implementation if they have no"
|
| + << "underlying_file_util";
|
| + return false;
|
| +}
|
| +
|
| +PlatformFileError FileSystemFileUtil::CopyOrMoveFile(
|
| + FileSystemOperationContext* context,
|
| + const FilePath& src_file_path,
|
| + const FilePath& dest_file_path,
|
| + bool copy) {
|
| + if (underlying_file_util_.get()) {
|
| + return underlying_file_util_->CopyOrMoveFile(
|
| + context, src_file_path, dest_file_path, copy);
|
| }
|
| - DCHECK_NE(base::kInvalidPlatformFileValue, file);
|
| - if (!base::TruncatePlatformFile(file, length))
|
| - error_code = base::PLATFORM_FILE_ERROR_FAILED;
|
| - base::ClosePlatformFile(file);
|
| - return error_code;
|
| + NOTREACHED() << "Subclasses must provide implementation if they have no"
|
| + << "underlying_file_util";
|
| + return base::PLATFORM_FILE_ERROR_FAILED;
|
| +}
|
| +
|
| +PlatformFileError FileSystemFileUtil::CopyInForeignFile(
|
| + FileSystemOperationContext* context,
|
| + const FilePath& src_file_path,
|
| + const FilePath& dest_file_path) {
|
| + if (underlying_file_util_.get()) {
|
| + return underlying_file_util_->CopyInForeignFile(
|
| + context, src_file_path, dest_file_path);
|
| + }
|
| + NOTREACHED() << "Subclasses must provide implementation if they have no"
|
| + << "underlying_file_util";
|
| + return base::PLATFORM_FILE_ERROR_FAILED;
|
| +}
|
| +
|
| +PlatformFileError FileSystemFileUtil::DeleteFile(
|
| + FileSystemOperationContext* context,
|
| + const FilePath& file_path) {
|
| + if (underlying_file_util_.get()) {
|
| + return underlying_file_util_->DeleteFile(context, file_path);
|
| + }
|
| + NOTREACHED() << "Subclasses must provide implementation if they have no"
|
| + << "underlying_file_util";
|
| + return base::PLATFORM_FILE_ERROR_FAILED;
|
| +}
|
| +
|
| +PlatformFileError FileSystemFileUtil::DeleteSingleDirectory(
|
| + FileSystemOperationContext* context,
|
| + const FilePath& file_path) {
|
| + if (underlying_file_util_.get()) {
|
| + return underlying_file_util_->DeleteSingleDirectory(context, file_path);
|
| + }
|
| + NOTREACHED() << "Subclasses must provide implementation if they have no"
|
| + << "underlying_file_util";
|
| + return base::PLATFORM_FILE_ERROR_FAILED;
|
| }
|
|
|
| PlatformFileError
|
| @@ -248,14 +305,13 @@ FileSystemFileUtil::PerformCommonCheckAndPreparationForMoveAndCopy(
|
| bool same_file_system =
|
| (context->src_origin_url() == context->dest_origin_url()) &&
|
| (context->src_type() == context->dest_type());
|
| - FileSystemFileUtil* dest_util = context->dest_file_system_file_util();
|
| + 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_system_file_util() ==
|
| - context->dest_file_system_file_util());
|
| + 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
|
| @@ -317,35 +373,12 @@ FileSystemFileUtil::PerformCommonCheckAndPreparationForMoveAndCopy(
|
| return base::PLATFORM_FILE_OK;
|
| }
|
|
|
| -PlatformFileError FileSystemFileUtil::CopyOrMoveFile(
|
| - FileSystemOperationContext* unused,
|
| - const FilePath& src_file_path,
|
| - const FilePath& dest_file_path,
|
| - bool copy) {
|
| - if (copy) {
|
| - if (file_util::CopyFile(src_file_path, dest_file_path))
|
| - return base::PLATFORM_FILE_OK;
|
| - } else {
|
| - DCHECK(!file_util::DirectoryExists(src_file_path));
|
| - if (file_util::Move(src_file_path, dest_file_path))
|
| - return base::PLATFORM_FILE_OK;
|
| - }
|
| - return base::PLATFORM_FILE_ERROR_FAILED;
|
| -}
|
| -
|
| -PlatformFileError FileSystemFileUtil::CopyInForeignFile(
|
| - FileSystemOperationContext* context,
|
| - const FilePath& src_file_path,
|
| - const FilePath& dest_file_path) {
|
| - return CopyOrMoveFile(context, src_file_path, dest_file_path, true);
|
| -}
|
| -
|
| PlatformFileError FileSystemFileUtil::CopyOrMoveDirectory(
|
| FileSystemOperationContext* context,
|
| const FilePath& src_file_path,
|
| const FilePath& dest_file_path,
|
| bool copy) {
|
| - FileSystemFileUtil* dest_util = context->dest_file_system_file_util();
|
| + 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.
|
| @@ -408,8 +441,7 @@ PlatformFileError FileSystemFileUtil::CopyOrMoveFileHelper(
|
| // 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_system_file_util() ==
|
| - context->dest_file_system_file_util());
|
| + DCHECK(context->src_file_util() == context->dest_file_util());
|
| return CopyOrMoveFile(context, src_file_path, dest_file_path, copy);
|
| }
|
| base::PlatformFileInfo file_info;
|
| @@ -420,45 +452,14 @@ PlatformFileError FileSystemFileUtil::CopyOrMoveFileHelper(
|
| if (error_code != base::PLATFORM_FILE_OK)
|
| return error_code;
|
|
|
| - DCHECK(context->dest_file_system_file_util());
|
| - error_code = context->dest_file_system_file_util()->CopyInForeignFile(
|
| + DCHECK(context->dest_file_util());
|
| + error_code = context->dest_file_util()->CopyInForeignFile(
|
| context, platform_file_path, dest_file_path);
|
| if (copy || error_code != base::PLATFORM_FILE_OK)
|
| return error_code;
|
| return DeleteFile(context, src_file_path);
|
| }
|
|
|
| -
|
| -PlatformFileError FileSystemFileUtil::DeleteFile(
|
| - FileSystemOperationContext* unused,
|
| - const FilePath& file_path) {
|
| - if (!file_util::PathExists(file_path))
|
| - return base::PLATFORM_FILE_ERROR_NOT_FOUND;
|
| - if (file_util::DirectoryExists(file_path))
|
| - return base::PLATFORM_FILE_ERROR_NOT_A_FILE;
|
| - if (!file_util::Delete(file_path, false))
|
| - return base::PLATFORM_FILE_ERROR_FAILED;
|
| - return base::PLATFORM_FILE_OK;
|
| -}
|
| -
|
| -PlatformFileError FileSystemFileUtil::DeleteSingleDirectory(
|
| - FileSystemOperationContext* unused,
|
| - const FilePath& file_path) {
|
| - if (!file_util::PathExists(file_path))
|
| - return base::PLATFORM_FILE_ERROR_NOT_FOUND;
|
| - if (!file_util::DirectoryExists(file_path)) {
|
| - // TODO(dmikurube): Check if this error code is appropriate.
|
| - return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY;
|
| - }
|
| - if (!file_util::IsDirectoryEmpty(file_path)) {
|
| - // TODO(dmikurube): Check if this error code is appropriate.
|
| - return base::PLATFORM_FILE_ERROR_NOT_EMPTY;
|
| - }
|
| - if (!file_util::Delete(file_path, false))
|
| - return base::PLATFORM_FILE_ERROR_FAILED;
|
| - return base::PLATFORM_FILE_OK;
|
| -}
|
| -
|
| PlatformFileError FileSystemFileUtil::DeleteDirectoryRecursive(
|
| FileSystemOperationContext* context,
|
| const FilePath& file_path) {
|
| @@ -491,67 +492,4 @@ PlatformFileError FileSystemFileUtil::DeleteDirectoryRecursive(
|
| return DeleteSingleDirectory(context, file_path);
|
| }
|
|
|
| -bool FileSystemFileUtil::PathExists(
|
| - FileSystemOperationContext* unused,
|
| - const FilePath& file_path) {
|
| - return file_util::PathExists(file_path);
|
| -}
|
| -
|
| -bool FileSystemFileUtil::DirectoryExists(
|
| - FileSystemOperationContext* unused,
|
| - const FilePath& file_path) {
|
| - return file_util::DirectoryExists(file_path);
|
| -}
|
| -
|
| -bool FileSystemFileUtil::IsDirectoryEmpty(
|
| - FileSystemOperationContext* unused,
|
| - const FilePath& file_path) {
|
| - return file_util::IsDirectoryEmpty(file_path);
|
| -}
|
| -
|
| -class FileSystemFileEnumerator
|
| - : public FileSystemFileUtil::AbstractFileEnumerator {
|
| - public:
|
| - FileSystemFileEnumerator(const FilePath& root_path,
|
| - bool recursive,
|
| - file_util::FileEnumerator::FileType file_type)
|
| - : file_enum_(root_path, recursive, file_type) {
|
| - }
|
| -
|
| - ~FileSystemFileEnumerator() {}
|
| -
|
| - virtual FilePath Next() OVERRIDE;
|
| - virtual int64 Size() OVERRIDE;
|
| - virtual bool IsDirectory() OVERRIDE;
|
| -
|
| - private:
|
| - file_util::FileEnumerator file_enum_;
|
| - file_util::FileEnumerator::FindInfo file_util_info_;
|
| -};
|
| -
|
| -FilePath FileSystemFileEnumerator::Next() {
|
| - FilePath rv = file_enum_.Next();
|
| - if (!rv.empty())
|
| - file_enum_.GetFindInfo(&file_util_info_);
|
| - return rv;
|
| -}
|
| -
|
| -int64 FileSystemFileEnumerator::Size() {
|
| - return file_util::FileEnumerator::GetFilesize(file_util_info_);
|
| -}
|
| -
|
| -bool FileSystemFileEnumerator::IsDirectory() {
|
| - return file_util::FileEnumerator::IsDirectory(file_util_info_);
|
| -}
|
| -
|
| -FileSystemFileUtil::AbstractFileEnumerator*
|
| -FileSystemFileUtil::CreateFileEnumerator(
|
| - FileSystemOperationContext* unused,
|
| - const FilePath& root_path) {
|
| - return new FileSystemFileEnumerator(
|
| - root_path, true, static_cast<file_util::FileEnumerator::FileType>(
|
| - file_util::FileEnumerator::FILES |
|
| - file_util::FileEnumerator::DIRECTORIES));
|
| -}
|
| -
|
| } // namespace fileapi
|
|
|