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 "base/platform_file.h" | |
13 #include "webkit/browser/fileapi/file_system_file_util.h" | 12 #include "webkit/browser/fileapi/file_system_file_util.h" |
14 #include "webkit/browser/webkit_storage_browser_export.h" | 13 #include "webkit/browser/webkit_storage_browser_export.h" |
15 | 14 |
16 namespace base { | 15 namespace base { |
17 class Time; | 16 class Time; |
18 } | 17 } |
19 | 18 |
20 namespace fileapi { | 19 namespace fileapi { |
21 | 20 |
22 // A thin wrapper class for accessing the OS native filesystem. | 21 // A thin wrapper class for accessing the OS native filesystem. |
23 // This performs common error checks necessary to implement FileUtil family | 22 // This performs common error checks necessary to implement FileUtil family |
24 // in addition to perform native filesystem operations. | 23 // in addition to perform native filesystem operations. |
25 // | 24 // |
26 // For the error checks it performs please see the comment for | 25 // For the error checks it performs please see the comment for |
27 // FileSystemFileUtil interface | 26 // FileSystemFileUtil interface |
28 // (webkit/browser/fileapi/file_system_file_util.h). | 27 // (webkit/browser/fileapi/file_system_file_util.h). |
29 // | 28 // |
30 // 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 |
31 // inherit from FileSystemFileUtil. | 30 // inherit from FileSystemFileUtil. |
32 class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE NativeFileUtil { | 31 class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE NativeFileUtil { |
33 public: | 32 public: |
34 enum CopyOrMoveMode { | 33 enum CopyOrMoveMode { |
35 COPY_NOSYNC, | 34 COPY_NOSYNC, |
36 COPY_SYNC, | 35 COPY_SYNC, |
37 MOVE | 36 MOVE |
38 }; | 37 }; |
39 static CopyOrMoveMode CopyOrMoveModeForDestination( | 38 static CopyOrMoveMode CopyOrMoveModeForDestination( |
40 const FileSystemURL& dest_url, bool copy); | 39 const FileSystemURL& dest_url, bool copy); |
41 | 40 |
42 static base::File::Error CreateOrOpen( | 41 static base::File CreateOrOpen(const base::FilePath& path, |
43 const base::FilePath& path, | 42 int file_flags); |
44 int file_flags, | |
45 base::PlatformFile* file_handle, | |
46 bool* created); | |
47 static base::File::Error Close(base::PlatformFile file); | |
48 static base::File::Error EnsureFileExists(const base::FilePath& path, | 43 static base::File::Error EnsureFileExists(const base::FilePath& path, |
49 bool* created); | 44 bool* created); |
50 static base::File::Error CreateDirectory(const base::FilePath& path, | 45 static base::File::Error CreateDirectory(const base::FilePath& path, |
51 bool exclusive, | 46 bool exclusive, |
52 bool recursive); | 47 bool recursive); |
53 static base::File::Error GetFileInfo(const base::FilePath& path, | 48 static base::File::Error GetFileInfo(const base::FilePath& path, |
54 base::File::Info* file_info); | 49 base::File::Info* file_info); |
55 static scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> | 50 static scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> |
56 CreateFileEnumerator(const base::FilePath& root_path, | 51 CreateFileEnumerator(const base::FilePath& root_path, |
57 bool recursive); | 52 bool recursive); |
58 static base::File::Error Touch(const base::FilePath& path, | 53 static base::File::Error Touch(const base::FilePath& path, |
59 const base::Time& last_access_time, | 54 const base::Time& last_access_time, |
60 const base::Time& last_modified_time); | 55 const base::Time& last_modified_time); |
61 static base::File::Error Truncate(const base::FilePath& path, | 56 static base::File::Error Truncate(const base::FilePath& path, |
62 int64 length); | 57 int64 length); |
63 static bool PathExists(const base::FilePath& path); | 58 static bool PathExists(const base::FilePath& path); |
64 static bool DirectoryExists(const base::FilePath& path); | 59 static bool DirectoryExists(const base::FilePath& path); |
65 static base::File::Error CopyOrMoveFile( | 60 static base::File::Error CopyOrMoveFile( |
66 const base::FilePath& src_path, | 61 const base::FilePath& src_path, |
67 const base::FilePath& dest_path, | 62 const base::FilePath& dest_path, |
68 FileSystemOperation::CopyOrMoveOption option, | 63 FileSystemOperation::CopyOrMoveOption option, |
69 CopyOrMoveMode mode); | 64 CopyOrMoveMode mode); |
70 static base::File::Error DeleteFile(const base::FilePath& path); | 65 static base::File::Error DeleteFile(const base::FilePath& path); |
71 static base::File::Error DeleteDirectory(const base::FilePath& path); | 66 static base::File::Error DeleteDirectory(const base::FilePath& path); |
72 | 67 |
73 private: | 68 private: |
74 DISALLOW_IMPLICIT_CONSTRUCTORS(NativeFileUtil); | 69 DISALLOW_IMPLICIT_CONSTRUCTORS(NativeFileUtil); |
75 }; | 70 }; |
76 | 71 |
77 } // namespace fileapi | 72 } // namespace fileapi |
78 | 73 |
79 #endif // WEBKIT_BROWSER_FILEAPI_NATIVE_FILE_UTIL_H_ | 74 #endif // WEBKIT_BROWSER_FILEAPI_NATIVE_FILE_UTIL_H_ |
OLD | NEW |