| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 BASE_FILE_UTIL_PROXY_H_ | 5 #ifndef BASE_FILE_UTIL_PROXY_H_ |
| 6 #define BASE_FILE_UTIL_PROXY_H_ | 6 #define BASE_FILE_UTIL_PROXY_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 93 |
| 94 static bool GetFileInfoFromPlatformFile( | 94 static bool GetFileInfoFromPlatformFile( |
| 95 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 95 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 96 PlatformFile file, | 96 PlatformFile file, |
| 97 GetFileInfoCallback* callback); | 97 GetFileInfoCallback* callback); |
| 98 | 98 |
| 99 static bool ReadDirectory(scoped_refptr<MessageLoopProxy> message_loop_proxy, | 99 static bool ReadDirectory(scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 100 const FilePath& file_path, | 100 const FilePath& file_path, |
| 101 ReadDirectoryCallback* callback); | 101 ReadDirectoryCallback* callback); |
| 102 | 102 |
| 103 // Creates directory at given path. It's an error to create |
| 104 // if |exclusive| is true and dir already exists. |
| 105 static bool CreateDirectory( |
| 106 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 107 const FilePath& file_path, |
| 108 bool exclusive, |
| 109 bool recursive, |
| 110 StatusCallback* callback); |
| 111 |
| 103 // Copies a file or a directory from |src_file_path| to |dest_file_path| | 112 // Copies a file or a directory from |src_file_path| to |dest_file_path| |
| 104 // Error cases: | 113 // Error cases: |
| 105 // If destination file doesn't exist or destination's parent | 114 // If destination file doesn't exist or destination's parent |
| 106 // doesn't exists. | 115 // doesn't exists. |
| 107 // If source dir exists but destination path is an existing file. | 116 // If source dir exists but destination path is an existing file. |
| 108 // If source file exists but destination path is an existing directory. | 117 // If source file exists but destination path is an existing directory. |
| 109 // If source is a parent of destination. | 118 // If source is a parent of destination. |
| 110 // If source doesn't exists. | 119 // If source doesn't exists. |
| 111 static bool Copy(scoped_refptr<MessageLoopProxy> message_loop_proxy, | 120 static bool Copy(scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 112 const FilePath& src_file_path, | 121 const FilePath& src_file_path, |
| 113 const FilePath& dest_file_path, | 122 const FilePath& dest_file_path, |
| 114 StatusCallback* callback); | 123 StatusCallback* callback); |
| 115 | 124 |
| 116 // Creates directory at given path. It's an error to create | 125 // Moves a file or a directory from src_file_path to dest_file_path. |
| 117 // if |exclusive| is true and dir already exists. | 126 // Error cases are similar to Copy method's error cases. |
| 118 static bool CreateDirectory( | 127 static bool Move( |
| 119 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 128 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 120 const FilePath& file_path, | 129 const FilePath& src_file_path, |
| 121 bool exclusive, | 130 const FilePath& dest_file_path, |
| 122 bool recursive, | |
| 123 StatusCallback* callback); | 131 StatusCallback* callback); |
| 124 | 132 |
| 125 // Deletes a file or a directory. | 133 // Deletes a file or a directory. |
| 126 // It is an error to delete a non-empty directory with recursive=false. | 134 // It is an error to delete a non-empty directory with recursive=false. |
| 127 static bool Delete(scoped_refptr<MessageLoopProxy> message_loop_proxy, | 135 static bool Delete(scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 128 const FilePath& file_path, | 136 const FilePath& file_path, |
| 129 bool recursive, | 137 bool recursive, |
| 130 StatusCallback* callback); | 138 StatusCallback* callback); |
| 131 | 139 |
| 132 // Moves a file or a directory from src_file_path to dest_file_path. | |
| 133 // Error cases are similar to Copy method's error cases. | |
| 134 static bool Move( | |
| 135 scoped_refptr<MessageLoopProxy> message_loop_proxy, | |
| 136 const FilePath& src_file_path, | |
| 137 const FilePath& dest_file_path, | |
| 138 StatusCallback* callback); | |
| 139 | |
| 140 // Deletes a directory and all of its contents. | 140 // Deletes a directory and all of its contents. |
| 141 static bool RecursiveDelete( | 141 static bool RecursiveDelete( |
| 142 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 142 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 143 const FilePath& file_path, | 143 const FilePath& file_path, |
| 144 StatusCallback* callback); | 144 StatusCallback* callback); |
| 145 | 145 |
| 146 // Reads from a file. On success, the file pointer is moved to position | 146 // Reads from a file. On success, the file pointer is moved to position |
| 147 // |offset + bytes_to_read| in the file. The callback can be NULL. | 147 // |offset + bytes_to_read| in the file. The callback can be NULL. |
| 148 static bool Read( | 148 static bool Read( |
| 149 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 149 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 PlatformFile file, | 204 PlatformFile file, |
| 205 StatusCallback* callback); | 205 StatusCallback* callback); |
| 206 | 206 |
| 207 private: | 207 private: |
| 208 DISALLOW_IMPLICIT_CONSTRUCTORS(FileUtilProxy); | 208 DISALLOW_IMPLICIT_CONSTRUCTORS(FileUtilProxy); |
| 209 }; | 209 }; |
| 210 | 210 |
| 211 } // namespace base | 211 } // namespace base |
| 212 | 212 |
| 213 #endif // BASE_FILE_UTIL_PROXY_H_ | 213 #endif // BASE_FILE_UTIL_PROXY_H_ |
| OLD | NEW |