Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(604)

Side by Side Diff: webkit/fileapi/local_file_system_file_util.h

Issue 6603034: Stop returning the true root path of each filesystem from openFileSystem.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 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.
4
5 #ifndef WEBKIT_FILEAPI_LOCAL_FILE_SYSTEM_FILE_UTIL_H_
6 #define WEBKIT_FILEAPI_LOCAL_FILE_SYSTEM_FILE_UTIL_H_
7
8 #include "base/callback.h"
9 #include "base/file_path.h"
10 #include "base/file_util.h"
11 #include "base/file_util_proxy.h"
12 #include "base/logging.h"
13 #include "base/platform_file.h"
14 #include "base/ref_counted.h"
15 #include "base/singleton.h"
16 #include "base/tracked_objects.h"
17 #include "webkit/fileapi/file_system_file_util.h"
18 #include "webkit/fileapi/file_system_types.h"
19
20 namespace base {
21 struct PlatformFileInfo;
22 class MessageLoopProxy;
23 class Time;
24 }
25
26 class GURL;
27
28 namespace fileapi {
29
30 using base::PlatformFile;
31 using base::PlatformFileError;
32
33 class FileSystemOperationContext;
34
35 class LocalFileSystemFileUtil : public FileSystemFileUtil {
36 public:
37 static LocalFileSystemFileUtil* GetInstance();
38
39 // Creates or opens a file with the given flags. It is invalid to pass NULL
40 // for the callback.
41 // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create
42 // a new file at the given |file_path| and calls back with
43 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists.
kinuko 2011/03/22 00:16:24 Should be ok to remove all the comments for the me
ericu 2011/03/22 00:40:31 Done.
44 virtual PlatformFileError CreateOrOpen(
45 FileSystemOperationContext* context,
46 const FilePath& file_path,
47 int file_flags,
48 PlatformFile* file_handle,
49 bool* created);
50
51 // Ensures that the given |file_path| exist. This creates a empty new file
52 // at |file_path| if the |file_path| does not exist.
53 // If a new file han not existed and is created at the |file_path|,
54 // |created| of the callback argument is set true and |error code|
55 // is set PLATFORM_FILE_OK.
56 // If the file already exists, |created| is set false and |error code|
57 // is set PLATFORM_FILE_OK.
58 // If the file hasn't existed but it couldn't be created for some other
59 // reasons, |created| is set false and |error code| indicates the error.
60 virtual PlatformFileError EnsureFileExists(
61 FileSystemOperationContext* context,
62 const FilePath& file_path, bool* created);
63
64 // Retrieves the information about a file. It is invalid to pass NULL for the
65 // callback.
66 virtual PlatformFileError GetFileInfo(
67 FileSystemOperationContext* context,
68 const FilePath& file_, base::PlatformFileInfo* file_info);
69
70 virtual PlatformFileError ReadDirectory(
71 FileSystemOperationContext* context,
72 const FilePath& file_path,
73 std::vector<base::FileUtilProxy::Entry>* entries);
74
75 // Creates directory at given path. It's an error to create
76 // if |exclusive| is true and dir already exists.
77 virtual PlatformFileError CreateDirectory(
78 FileSystemOperationContext* context,
79 const FilePath& file_path,
80 bool exclusive,
81 bool recursive);
82
83 // Copies a file or a directory from |src_file_path| to |dest_file_path|
84 // Error cases:
85 // If destination file doesn't exist or destination's parent
86 // doesn't exists.
87 // If source dir exists but destination path is an existing file.
88 // If source file exists but destination path is an existing directory.
89 // If source is a parent of destination.
90 // If source doesn't exists.
91 virtual PlatformFileError Copy(
92 FileSystemOperationContext* context,
93 const FilePath& src_file_path,
94 const FilePath& dest_file_path);
95
96 // Moves a file or a directory from src_file_path to dest_file_path.
97 // Error cases are similar to Copy method's error cases.
98 virtual PlatformFileError Move(
99 FileSystemOperationContext* context,
100 const FilePath& src_file_path,
101 const FilePath& dest_file_path);
102
103 // Deletes a file or a directory.
104 // It is an error to delete a non-empty directory with recursive=false.
105 virtual PlatformFileError Delete(
106 FileSystemOperationContext* context,
107 const FilePath& file_path,
108 bool recursive);
109
110 // Touches a file. The callback can be NULL.
111 virtual PlatformFileError Touch(
112 FileSystemOperationContext* context,
113 const FilePath& file_path,
114 const base::Time& last_access_time,
115 const base::Time& last_modified_time);
116
117 // Truncates a file to the given length. If |length| is greater than the
118 // current length of the file, the file will be extended with zeroes.
119 // The callback can be NULL.
120 virtual PlatformFileError Truncate(
121 FileSystemOperationContext* context,
122 const FilePath& path,
123 int64 length);
124
125 protected:
126 LocalFileSystemFileUtil() { }
127
128 friend struct DefaultSingletonTraits<LocalFileSystemFileUtil>;
129 DISALLOW_COPY_AND_ASSIGN(LocalFileSystemFileUtil);
130
131 private:
132 // Given the filesystem's root URL and a virtual path, produces a real, full
133 // local path.
134 FilePath GetLocalPath(
135 FileSystemOperationContext* context,
136 const GURL& origin_url,
137 FileSystemType type,
138 const FilePath& virtual_path);
139
140 };
141
142 } // namespace fileapi
143
144 #endif // WEBKIT_FILEAPI_LOCAL_FILE_SYSTEM_FILE_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698