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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 // don't exist. Returns 'true' on successful creation, or if the directory | 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. | 255 // already exists. The directory is only readable by the current user. |
256 // Returns true on success, leaving *error unchanged. | 256 // Returns true on success, leaving *error unchanged. |
257 // Returns false on failure and sets *error appropriately, if it is non-NULL. | 257 // Returns false on failure and sets *error appropriately, if it is non-NULL. |
258 BASE_EXPORT bool CreateDirectoryAndGetError(const FilePath& full_path, | 258 BASE_EXPORT bool CreateDirectoryAndGetError(const FilePath& full_path, |
259 PlatformFileError* error); | 259 PlatformFileError* error); |
260 | 260 |
261 // Backward-compatible convenience method for the above. | 261 // Backward-compatible convenience method for the above. |
262 BASE_EXPORT bool CreateDirectory(const FilePath& full_path); | 262 BASE_EXPORT bool CreateDirectory(const FilePath& full_path); |
263 | 263 |
264 } // namespace base | |
265 | |
266 // ----------------------------------------------------------------------------- | |
267 | |
268 namespace file_util { | |
269 | |
270 // Returns the file size. Returns true on success. | 264 // Returns the file size. Returns true on success. |
271 BASE_EXPORT bool GetFileSize(const base::FilePath& file_path, int64* file_size); | 265 BASE_EXPORT bool GetFileSize(const FilePath& file_path, int64* file_size); |
272 | 266 |
273 // Sets |real_path| to |path| with symbolic links and junctions expanded. | 267 // Sets |real_path| to |path| with symbolic links and junctions expanded. |
274 // On windows, make sure the path starts with a lettered drive. | 268 // On windows, make sure the path starts with a lettered drive. |
275 // |path| must reference a file. Function will fail if |path| points to | 269 // |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 | 270 // 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, | 271 // 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. | 272 // or if |real_path| would be longer than MAX_PATH characters. |
279 BASE_EXPORT bool NormalizeFilePath(const base::FilePath& path, | 273 BASE_EXPORT bool NormalizeFilePath(const FilePath& path, FilePath* real_path); |
280 base::FilePath* real_path); | 274 |
| 275 } // namespace base |
| 276 |
| 277 // ----------------------------------------------------------------------------- |
| 278 |
| 279 namespace file_util { |
281 | 280 |
282 #if defined(OS_WIN) | 281 #if defined(OS_WIN) |
283 | 282 |
284 // Given a path in NT native form ("\Device\HarddiskVolumeXX\..."), | 283 // Given a path in NT native form ("\Device\HarddiskVolumeXX\..."), |
285 // return in |drive_letter_path| the equivalent path that starts with | 284 // return in |drive_letter_path| the equivalent path that starts with |
286 // a drive letter ("C:\..."). Return false if no such path exists. | 285 // a drive letter ("C:\..."). Return false if no such path exists. |
287 BASE_EXPORT bool DevicePathToDriveLetterPath(const base::FilePath& device_path, | 286 BASE_EXPORT bool DevicePathToDriveLetterPath(const base::FilePath& device_path, |
288 base::FilePath* drive_letter_path); | 287 base::FilePath* drive_letter_path); |
289 | 288 |
290 // Given an existing file in |path|, set |real_path| to the path | 289 // Given an existing file in |path|, set |real_path| to the path |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 // This function simulates Move(), but unlike Move() it works across volumes. | 466 // This function simulates Move(), but unlike Move() it works across volumes. |
468 // This function is not transactional. | 467 // This function is not transactional. |
469 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, | 468 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, |
470 const FilePath& to_path); | 469 const FilePath& to_path); |
471 #endif // defined(OS_WIN) | 470 #endif // defined(OS_WIN) |
472 | 471 |
473 } // namespace internal | 472 } // namespace internal |
474 } // namespace base | 473 } // namespace base |
475 | 474 |
476 #endif // BASE_FILE_UTIL_H_ | 475 #endif // BASE_FILE_UTIL_H_ |
OLD | NEW |