| Index: storage/browser/fileapi/native_file_util.cc
|
| diff --git a/webkit/browser/fileapi/native_file_util.cc b/storage/browser/fileapi/native_file_util.cc
|
| similarity index 79%
|
| rename from webkit/browser/fileapi/native_file_util.cc
|
| rename to storage/browser/fileapi/native_file_util.cc
|
| index c0229943b9afd8494e3f4a2332423bd0a9de140f..2dcb09f3b60d27919f605e5aeae55f28a14396ab 100644
|
| --- a/webkit/browser/fileapi/native_file_util.cc
|
| +++ b/storage/browser/fileapi/native_file_util.cc
|
| @@ -2,16 +2,16 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "webkit/browser/fileapi/native_file_util.h"
|
| +#include "storage/browser/fileapi/native_file_util.h"
|
|
|
| #include "base/file_util.h"
|
| #include "base/files/file.h"
|
| #include "base/files/file_enumerator.h"
|
| #include "base/memory/scoped_ptr.h"
|
| -#include "webkit/browser/fileapi/file_system_operation_context.h"
|
| -#include "webkit/browser/fileapi/file_system_url.h"
|
| +#include "storage/browser/fileapi/file_system_operation_context.h"
|
| +#include "storage/browser/fileapi/file_system_url.h"
|
|
|
| -namespace fileapi {
|
| +namespace storage {
|
|
|
| namespace {
|
|
|
| @@ -21,17 +21,17 @@ namespace {
|
| // TODO(benchan): Find a better place outside webkit to host this function.
|
| bool SetPlatformSpecificDirectoryPermissions(const base::FilePath& dir_path) {
|
| #if defined(OS_CHROMEOS)
|
| - // System daemons on Chrome OS may run as a user different than the Chrome
|
| - // process but need to access files under the directories created here.
|
| - // Because of that, grant the execute permission on the created directory
|
| - // to group and other users.
|
| - if (HANDLE_EINTR(chmod(dir_path.value().c_str(),
|
| - S_IRWXU | S_IXGRP | S_IXOTH)) != 0) {
|
| - return false;
|
| - }
|
| + // System daemons on Chrome OS may run as a user different than the Chrome
|
| + // process but need to access files under the directories created here.
|
| + // Because of that, grant the execute permission on the created directory
|
| + // to group and other users.
|
| + if (HANDLE_EINTR(
|
| + chmod(dir_path.value().c_str(), S_IRWXU | S_IXGRP | S_IXOTH)) != 0) {
|
| + return false;
|
| + }
|
| #endif
|
| - // Keep the directory permissions unchanged on non-Chrome OS platforms.
|
| - return true;
|
| + // Keep the directory permissions unchanged on non-Chrome OS platforms.
|
| + return true;
|
| }
|
|
|
| // Copies a file |from| to |to|, and ensure the written content is synced to
|
| @@ -57,7 +57,7 @@ bool CopyFileAndSync(const base::FilePath& from, const base::FilePath& to) {
|
| return false;
|
| if (bytes_read == 0)
|
| break;
|
| - for (int bytes_written = 0; bytes_written < bytes_read; ) {
|
| + for (int bytes_written = 0; bytes_written < bytes_read;) {
|
| int bytes_written_partial = outfile.WriteAtCurrentPos(
|
| &buffer[bytes_written], bytes_read - bytes_written);
|
| if (bytes_written_partial < 0)
|
| @@ -78,8 +78,7 @@ class NativeFileEnumerator : public FileSystemFileUtil::AbstractFileEnumerator {
|
| NativeFileEnumerator(const base::FilePath& root_path,
|
| bool recursive,
|
| int file_type)
|
| - : file_enum_(root_path, recursive, file_type) {
|
| - }
|
| + : file_enum_(root_path, recursive, file_type) {}
|
|
|
| virtual ~NativeFileEnumerator() {}
|
|
|
| @@ -113,10 +112,12 @@ bool NativeFileEnumerator::IsDirectory() {
|
| }
|
|
|
| NativeFileUtil::CopyOrMoveMode NativeFileUtil::CopyOrMoveModeForDestination(
|
| - const FileSystemURL& dest_url, bool copy) {
|
| + const FileSystemURL& dest_url,
|
| + bool copy) {
|
| if (copy) {
|
| - return dest_url.mount_option().copy_sync_option() == COPY_SYNC_OPTION_SYNC ?
|
| - COPY_SYNC : COPY_NOSYNC;
|
| + return dest_url.mount_option().copy_sync_option() == COPY_SYNC_OPTION_SYNC
|
| + ? COPY_SYNC
|
| + : COPY_NOSYNC;
|
| }
|
| return MOVE;
|
| }
|
| @@ -135,9 +136,8 @@ base::File NativeFileUtil::CreateOrOpen(const base::FilePath& path,
|
| return base::File(path, file_flags);
|
| }
|
|
|
| -base::File::Error NativeFileUtil::EnsureFileExists(
|
| - const base::FilePath& path,
|
| - bool* created) {
|
| +base::File::Error NativeFileUtil::EnsureFileExists(const base::FilePath& path,
|
| + bool* created) {
|
| if (!base::DirectoryExists(path.DirName()))
|
| // If its parent does not exist, should return NOT_FOUND error.
|
| return base::File::FILE_ERROR_NOT_FOUND;
|
| @@ -162,10 +162,9 @@ base::File::Error NativeFileUtil::EnsureFileExists(
|
| return error_code;
|
| }
|
|
|
| -base::File::Error NativeFileUtil::CreateDirectory(
|
| - const base::FilePath& path,
|
| - bool exclusive,
|
| - bool recursive) {
|
| +base::File::Error NativeFileUtil::CreateDirectory(const base::FilePath& path,
|
| + bool exclusive,
|
| + bool recursive) {
|
| // If parent dir of file doesn't exist.
|
| if (!recursive && !base::PathExists(path.DirName()))
|
| return base::File::FILE_ERROR_NOT_FOUND;
|
| @@ -185,15 +184,14 @@ base::File::Error NativeFileUtil::CreateDirectory(
|
| // Since some file systems don't support permission setting, we do not treat
|
| // an error from the function as the failure of copying. Just log it.
|
| LOG(WARNING) << "Setting directory permission failed: "
|
| - << path.AsUTF8Unsafe();
|
| + << path.AsUTF8Unsafe();
|
| }
|
|
|
| return base::File::FILE_OK;
|
| }
|
|
|
| -base::File::Error NativeFileUtil::GetFileInfo(
|
| - const base::FilePath& path,
|
| - base::File::Info* file_info) {
|
| +base::File::Error NativeFileUtil::GetFileInfo(const base::FilePath& path,
|
| + base::File::Info* file_info) {
|
| if (!base::PathExists(path))
|
| return base::File::FILE_ERROR_NOT_FOUND;
|
|
|
| @@ -203,18 +201,19 @@ base::File::Error NativeFileUtil::GetFileInfo(
|
| }
|
|
|
| scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator>
|
| - NativeFileUtil::CreateFileEnumerator(const base::FilePath& root_path,
|
| - bool recursive) {
|
| - return make_scoped_ptr(new NativeFileEnumerator(
|
| - root_path, recursive,
|
| - base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES))
|
| +NativeFileUtil::CreateFileEnumerator(const base::FilePath& root_path,
|
| + bool recursive) {
|
| + return make_scoped_ptr(
|
| + new NativeFileEnumerator(root_path,
|
| + recursive,
|
| + base::FileEnumerator::FILES |
|
| + base::FileEnumerator::DIRECTORIES))
|
| .PassAs<FileSystemFileUtil::AbstractFileEnumerator>();
|
| }
|
|
|
| -base::File::Error NativeFileUtil::Touch(
|
| - const base::FilePath& path,
|
| - const base::Time& last_access_time,
|
| - const base::Time& last_modified_time) {
|
| +base::File::Error NativeFileUtil::Touch(const base::FilePath& path,
|
| + const base::Time& last_access_time,
|
| + const base::Time& last_modified_time) {
|
| if (!base::TouchFile(path, last_access_time, last_modified_time))
|
| return base::File::FILE_ERROR_FAILED;
|
| return base::File::FILE_OK;
|
| @@ -254,8 +253,7 @@ base::File::Error NativeFileUtil::CopyOrMoveFile(
|
| base::Time last_modified = info.last_modified;
|
|
|
| error = NativeFileUtil::GetFileInfo(dest_path, &info);
|
| - if (error != base::File::FILE_OK &&
|
| - error != base::File::FILE_ERROR_NOT_FOUND)
|
| + if (error != base::File::FILE_OK && error != base::File::FILE_ERROR_NOT_FOUND)
|
| return error;
|
| if (info.is_directory)
|
| return base::File::FILE_ERROR_INVALID_OPERATION;
|
| @@ -312,4 +310,4 @@ base::File::Error NativeFileUtil::DeleteDirectory(const base::FilePath& path) {
|
| return base::File::FILE_OK;
|
| }
|
|
|
| -} // namespace fileapi
|
| +} // namespace storage
|
|
|