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
3 // found in the LICENSE file.
5 #ifndef WEBKIT_BROWSER_FILEAPI_NATIVE_FILE_UTIL_H_
6 #define WEBKIT_BROWSER_FILEAPI_NATIVE_FILE_UTIL_H_
8 #include "base/files/file_path.h"
9 #include "base/files/file_util_proxy.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/platform_file.h"
12 #include "webkit/browser/fileapi/file_system_file_util.h"
13 #include "webkit/browser/webkit_storage_browser_export.h"
21 // A thin wrapper class for accessing the OS native filesystem.
22 // This performs common error checks necessary to implement FileUtil family
23 // in addition to perform native filesystem operations.
25 // For the error checks it performs please see the comment for
26 // FileSystemFileUtil interface
27 // (webkit/browser/fileapi/file_system_file_util.h).
29 // Note that all the methods of this class are static and this does NOT
30 // inherit from FileSystemFileUtil.
31 class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE NativeFileUtil
{
33 static base::PlatformFileError
CreateOrOpen(
34 const base::FilePath
& path
,
36 base::PlatformFile
* file_handle
,
38 static base::PlatformFileError
Close(base::PlatformFile file
);
39 static base::PlatformFileError
EnsureFileExists(const base::FilePath
& path
,
41 static base::PlatformFileError
CreateDirectory(const base::FilePath
& path
,
44 static base::PlatformFileError
GetFileInfo(const base::FilePath
& path
,
45 base::PlatformFileInfo
* file_info
);
46 static scoped_ptr
<FileSystemFileUtil::AbstractFileEnumerator
>
47 CreateFileEnumerator(const base::FilePath
& root_path
,
49 static base::PlatformFileError
Touch(const base::FilePath
& path
,
50 const base::Time
& last_access_time
,
51 const base::Time
& last_modified_time
);
52 static base::PlatformFileError
Truncate(const base::FilePath
& path
,
54 static bool PathExists(const base::FilePath
& path
);
55 static bool DirectoryExists(const base::FilePath
& path
);
56 static base::PlatformFileError
CopyOrMoveFile(
57 const base::FilePath
& src_path
,
58 const base::FilePath
& dest_path
,
59 FileSystemOperation::CopyOrMoveOption option
,
61 static base::PlatformFileError
DeleteFile(const base::FilePath
& path
);
62 static base::PlatformFileError
DeleteDirectory(const base::FilePath
& path
);
65 DISALLOW_IMPLICIT_CONSTRUCTORS(NativeFileUtil
);
68 } // namespace fileapi
70 #endif // WEBKIT_BROWSER_FILEAPI_NATIVE_FILE_UTIL_H_