| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WEBKIT_BROWSER_FILEAPI_NATIVE_FILE_UTIL_H_ | 5 #ifndef WEBKIT_BROWSER_FILEAPI_NATIVE_FILE_UTIL_H_ |
| 6 #define WEBKIT_BROWSER_FILEAPI_NATIVE_FILE_UTIL_H_ | 6 #define WEBKIT_BROWSER_FILEAPI_NATIVE_FILE_UTIL_H_ |
| 7 | 7 |
| 8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util_proxy.h" | 10 #include "base/files/file_util_proxy.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "webkit/browser/fileapi/file_system_file_util.h" | 12 #include "storage/browser/fileapi/file_system_file_util.h" |
| 13 #include "webkit/browser/webkit_storage_browser_export.h" | 13 #include "storage/common/storage_export.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class Time; | 16 class Time; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace fileapi { | 19 namespace storage { |
| 20 | 20 |
| 21 // A thin wrapper class for accessing the OS native filesystem. | 21 // A thin wrapper class for accessing the OS native filesystem. |
| 22 // This performs common error checks necessary to implement FileUtil family | 22 // This performs common error checks necessary to implement FileUtil family |
| 23 // in addition to perform native filesystem operations. | 23 // in addition to perform native filesystem operations. |
| 24 // | 24 // |
| 25 // For the error checks it performs please see the comment for | 25 // For the error checks it performs please see the comment for |
| 26 // FileSystemFileUtil interface | 26 // FileSystemFileUtil interface |
| 27 // (webkit/browser/fileapi/file_system_file_util.h). | 27 // (storage/browser/fileapi/file_system_file_util.h). |
| 28 // | 28 // |
| 29 // Note that all the methods of this class are static and this does NOT | 29 // Note that all the methods of this class are static and this does NOT |
| 30 // inherit from FileSystemFileUtil. | 30 // inherit from FileSystemFileUtil. |
| 31 class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE NativeFileUtil { | 31 class STORAGE_EXPORT_PRIVATE NativeFileUtil { |
| 32 public: | 32 public: |
| 33 enum CopyOrMoveMode { | 33 enum CopyOrMoveMode { COPY_NOSYNC, COPY_SYNC, MOVE }; |
| 34 COPY_NOSYNC, | |
| 35 COPY_SYNC, | |
| 36 MOVE | |
| 37 }; | |
| 38 static CopyOrMoveMode CopyOrMoveModeForDestination( | 34 static CopyOrMoveMode CopyOrMoveModeForDestination( |
| 39 const FileSystemURL& dest_url, bool copy); | 35 const FileSystemURL& dest_url, |
| 36 bool copy); |
| 40 | 37 |
| 41 static base::File CreateOrOpen(const base::FilePath& path, int file_flags); | 38 static base::File CreateOrOpen(const base::FilePath& path, int file_flags); |
| 42 static base::File::Error EnsureFileExists(const base::FilePath& path, | 39 static base::File::Error EnsureFileExists(const base::FilePath& path, |
| 43 bool* created); | 40 bool* created); |
| 44 static base::File::Error CreateDirectory(const base::FilePath& path, | 41 static base::File::Error CreateDirectory(const base::FilePath& path, |
| 45 bool exclusive, | 42 bool exclusive, |
| 46 bool recursive); | 43 bool recursive); |
| 47 static base::File::Error GetFileInfo(const base::FilePath& path, | 44 static base::File::Error GetFileInfo(const base::FilePath& path, |
| 48 base::File::Info* file_info); | 45 base::File::Info* file_info); |
| 49 static scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> | 46 static scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> |
| 50 CreateFileEnumerator(const base::FilePath& root_path, | 47 CreateFileEnumerator(const base::FilePath& root_path, bool recursive); |
| 51 bool recursive); | |
| 52 static base::File::Error Touch(const base::FilePath& path, | 48 static base::File::Error Touch(const base::FilePath& path, |
| 53 const base::Time& last_access_time, | 49 const base::Time& last_access_time, |
| 54 const base::Time& last_modified_time); | 50 const base::Time& last_modified_time); |
| 55 static base::File::Error Truncate(const base::FilePath& path, | 51 static base::File::Error Truncate(const base::FilePath& path, int64 length); |
| 56 int64 length); | |
| 57 static bool PathExists(const base::FilePath& path); | 52 static bool PathExists(const base::FilePath& path); |
| 58 static bool DirectoryExists(const base::FilePath& path); | 53 static bool DirectoryExists(const base::FilePath& path); |
| 59 static base::File::Error CopyOrMoveFile( | 54 static base::File::Error CopyOrMoveFile( |
| 60 const base::FilePath& src_path, | 55 const base::FilePath& src_path, |
| 61 const base::FilePath& dest_path, | 56 const base::FilePath& dest_path, |
| 62 FileSystemOperation::CopyOrMoveOption option, | 57 FileSystemOperation::CopyOrMoveOption option, |
| 63 CopyOrMoveMode mode); | 58 CopyOrMoveMode mode); |
| 64 static base::File::Error DeleteFile(const base::FilePath& path); | 59 static base::File::Error DeleteFile(const base::FilePath& path); |
| 65 static base::File::Error DeleteDirectory(const base::FilePath& path); | 60 static base::File::Error DeleteDirectory(const base::FilePath& path); |
| 66 | 61 |
| 67 private: | 62 private: |
| 68 DISALLOW_IMPLICIT_CONSTRUCTORS(NativeFileUtil); | 63 DISALLOW_IMPLICIT_CONSTRUCTORS(NativeFileUtil); |
| 69 }; | 64 }; |
| 70 | 65 |
| 71 } // namespace fileapi | 66 } // namespace storage |
| 72 | 67 |
| 73 #endif // WEBKIT_BROWSER_FILEAPI_NATIVE_FILE_UTIL_H_ | 68 #endif // WEBKIT_BROWSER_FILEAPI_NATIVE_FILE_UTIL_H_ |
| OLD | NEW |