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 // This file contains utility functions for dealing with the local | 5 // This file contains utility functions for dealing with the local |
6 // filesystem. | 6 // filesystem. |
7 | 7 |
8 #ifndef BASE_FILE_UTIL_H_ | 8 #ifndef BASE_FILE_UTIL_H_ |
9 #define BASE_FILE_UTIL_H_ | 9 #define BASE_FILE_UTIL_H_ |
10 | 10 |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 BASE_EXPORT bool CreateNewTempDirectory(const FilePath::StringType& prefix, | 243 BASE_EXPORT bool CreateNewTempDirectory(const FilePath::StringType& prefix, |
244 FilePath* new_temp_path); | 244 FilePath* new_temp_path); |
245 | 245 |
246 // Create a directory within another directory. | 246 // Create a directory within another directory. |
247 // Extra characters will be appended to |prefix| to ensure that the | 247 // Extra characters will be appended to |prefix| to ensure that the |
248 // new directory does not have the same name as an existing directory. | 248 // new directory does not have the same name as an existing directory. |
249 BASE_EXPORT bool CreateTemporaryDirInDir(const FilePath& base_dir, | 249 BASE_EXPORT bool CreateTemporaryDirInDir(const FilePath& base_dir, |
250 const FilePath::StringType& prefix, | 250 const FilePath::StringType& prefix, |
251 FilePath* new_dir); | 251 FilePath* new_dir); |
252 | 252 |
| 253 // Creates a directory, as well as creating any parent directories, if they |
| 254 // don't exist. Returns 'true' on successful creation, or if the directory |
| 255 // already exists. The directory is only readable by the current user. |
| 256 // Returns true on success, leaving *error unchanged. |
| 257 // Returns false on failure and sets *error appropriately, if it is non-NULL. |
| 258 BASE_EXPORT bool CreateDirectoryAndGetError(const FilePath& full_path, |
| 259 PlatformFileError* error); |
| 260 |
| 261 // Backward-compatible convenience method for the above. |
| 262 BASE_EXPORT bool CreateDirectory(const FilePath& full_path); |
| 263 |
253 } // namespace base | 264 } // namespace base |
254 | 265 |
255 // ----------------------------------------------------------------------------- | 266 // ----------------------------------------------------------------------------- |
256 | 267 |
257 namespace file_util { | 268 namespace file_util { |
258 | 269 |
259 // Creates a directory, as well as creating any parent directories, if they | |
260 // don't exist. Returns 'true' on successful creation, or if the directory | |
261 // already exists. The directory is only readable by the current user. | |
262 // Returns true on success, leaving *error unchanged. | |
263 // Returns false on failure and sets *error appropriately, if it is non-NULL. | |
264 BASE_EXPORT bool CreateDirectoryAndGetError(const base::FilePath& full_path, | |
265 base::PlatformFileError* error); | |
266 | |
267 // Backward-compatible convenience method for the above. | |
268 BASE_EXPORT bool CreateDirectory(const base::FilePath& full_path); | |
269 | |
270 // Returns the file size. Returns true on success. | 270 // Returns the file size. Returns true on success. |
271 BASE_EXPORT bool GetFileSize(const base::FilePath& file_path, int64* file_size); | 271 BASE_EXPORT bool GetFileSize(const base::FilePath& file_path, int64* file_size); |
272 | 272 |
273 // Sets |real_path| to |path| with symbolic links and junctions expanded. | 273 // Sets |real_path| to |path| with symbolic links and junctions expanded. |
274 // On windows, make sure the path starts with a lettered drive. | 274 // On windows, make sure the path starts with a lettered drive. |
275 // |path| must reference a file. Function will fail if |path| points to | 275 // |path| must reference a file. Function will fail if |path| points to |
276 // a directory or to a nonexistent path. On windows, this function will | 276 // a directory or to a nonexistent path. On windows, this function will |
277 // fail if |path| is a junction or symlink that points to an empty file, | 277 // fail if |path| is a junction or symlink that points to an empty file, |
278 // or if |real_path| would be longer than MAX_PATH characters. | 278 // or if |real_path| would be longer than MAX_PATH characters. |
279 BASE_EXPORT bool NormalizeFilePath(const base::FilePath& path, | 279 BASE_EXPORT bool NormalizeFilePath(const base::FilePath& path, |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 // This function simulates Move(), but unlike Move() it works across volumes. | 467 // This function simulates Move(), but unlike Move() it works across volumes. |
468 // This function is not transactional. | 468 // This function is not transactional. |
469 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, | 469 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, |
470 const FilePath& to_path); | 470 const FilePath& to_path); |
471 #endif // defined(OS_WIN) | 471 #endif // defined(OS_WIN) |
472 | 472 |
473 } // namespace internal | 473 } // namespace internal |
474 } // namespace base | 474 } // namespace base |
475 | 475 |
476 #endif // BASE_FILE_UTIL_H_ | 476 #endif // BASE_FILE_UTIL_H_ |
OLD | NEW |