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_FILEAPI_NATIVE_FILE_UTIL_H_ | 5 #ifndef WEBKIT_FILEAPI_NATIVE_FILE_UTIL_H_ |
6 #define WEBKIT_FILEAPI_NATIVE_FILE_UTIL_H_ | 6 #define WEBKIT_FILEAPI_NATIVE_FILE_UTIL_H_ |
7 | 7 |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util_proxy.h" | 9 #include "base/file_util_proxy.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/platform_file.h" | 11 #include "base/platform_file.h" |
12 #include "webkit/fileapi/file_system_file_util.h" | 12 #include "webkit/fileapi/file_system_file_util.h" |
13 #include "webkit/storage/webkit_storage_export.h" | 13 #include "webkit/storage/webkit_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 fileapi { |
20 | 20 |
21 using base::PlatformFile; | |
22 using base::PlatformFileError; | |
23 | |
24 // TODO(dmikurube): Add unit tests for NativeFileUtil. | 21 // TODO(dmikurube): Add unit tests for NativeFileUtil. |
25 // This class handles accessing the OS native filesystem. | 22 // This class handles accessing the OS native filesystem. |
26 class WEBKIT_STORAGE_EXPORT_PRIVATE NativeFileUtil { | 23 class WEBKIT_STORAGE_EXPORT_PRIVATE NativeFileUtil { |
27 public: | 24 public: |
28 static PlatformFileError CreateOrOpen( | 25 static base::PlatformFileError CreateOrOpen( |
29 const FilePath& path, | 26 const FilePath& path, |
30 int file_flags, | 27 int file_flags, |
31 PlatformFile* file_handle, | 28 base::PlatformFile* file_handle, |
32 bool* created); | 29 bool* created); |
33 static PlatformFileError Close(PlatformFile file); | 30 static base::PlatformFileError Close(base::PlatformFile file); |
34 static PlatformFileError EnsureFileExists(const FilePath& path, | 31 static base::PlatformFileError EnsureFileExists(const FilePath& path, |
35 bool* created); | 32 bool* created); |
36 static PlatformFileError CreateDirectory(const FilePath& path, | 33 static base::PlatformFileError CreateDirectory(const FilePath& path, |
37 bool exclusive, | 34 bool exclusive, |
38 bool recursive); | 35 bool recursive); |
39 static PlatformFileError GetFileInfo(const FilePath& path, | 36 static base::PlatformFileError GetFileInfo(const FilePath& path, |
40 base::PlatformFileInfo* file_info); | 37 base::PlatformFileInfo* file_info); |
41 static scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> | 38 static scoped_ptr<FileSystemFileUtil::AbstractFileEnumerator> |
42 CreateFileEnumerator(const FilePath& root_path, | 39 CreateFileEnumerator(const FilePath& root_path, |
43 bool recursive); | 40 bool recursive); |
44 static PlatformFileError Touch(const FilePath& path, | 41 static base::PlatformFileError Touch(const FilePath& path, |
45 const base::Time& last_access_time, | 42 const base::Time& last_access_time, |
46 const base::Time& last_modified_time); | 43 const base::Time& last_modified_time); |
47 static PlatformFileError Truncate(const FilePath& path, int64 length); | 44 static base::PlatformFileError Truncate(const FilePath& path, int64 length); |
48 static bool PathExists(const FilePath& path); | 45 static bool PathExists(const FilePath& path); |
49 static bool DirectoryExists(const FilePath& path); | 46 static bool DirectoryExists(const FilePath& path); |
50 static bool IsDirectoryEmpty(const FilePath& path); | 47 static bool IsDirectoryEmpty(const FilePath& path); |
51 static PlatformFileError CopyOrMoveFile(const FilePath& src_path, | 48 static base::PlatformFileError CopyOrMoveFile(const FilePath& src_path, |
52 const FilePath& dest_path, | 49 const FilePath& dest_path, |
53 bool copy); | 50 bool copy); |
54 static PlatformFileError DeleteFile(const FilePath& path); | 51 static base::PlatformFileError DeleteFile(const FilePath& path); |
55 static PlatformFileError DeleteSingleDirectory(const FilePath& path); | 52 static base::PlatformFileError DeleteSingleDirectory(const FilePath& path); |
56 | 53 |
57 private: | 54 private: |
58 DISALLOW_IMPLICIT_CONSTRUCTORS(NativeFileUtil); | 55 DISALLOW_IMPLICIT_CONSTRUCTORS(NativeFileUtil); |
59 }; | 56 }; |
60 | 57 |
61 } // namespace fileapi | 58 } // namespace fileapi |
62 | 59 |
63 #endif // WEBKIT_FILEAPI_NATIVE_FILE_UTIL_H_ | 60 #endif // WEBKIT_FILEAPI_NATIVE_FILE_UTIL_H_ |
OLD | NEW |