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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 BASE_EXPORT bool GetFileSize(const FilePath& file_path, int64* file_size); | 265 BASE_EXPORT bool GetFileSize(const FilePath& file_path, int64* file_size); |
266 | 266 |
267 // Sets |real_path| to |path| with symbolic links and junctions expanded. | 267 // Sets |real_path| to |path| with symbolic links and junctions expanded. |
268 // On windows, make sure the path starts with a lettered drive. | 268 // On windows, make sure the path starts with a lettered drive. |
269 // |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 |
270 // 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 |
271 // 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, |
272 // or if |real_path| would be longer than MAX_PATH characters. | 272 // or if |real_path| would be longer than MAX_PATH characters. |
273 BASE_EXPORT bool NormalizeFilePath(const FilePath& path, FilePath* real_path); | 273 BASE_EXPORT bool NormalizeFilePath(const FilePath& path, FilePath* real_path); |
274 | 274 |
| 275 #if defined(OS_WIN) |
| 276 |
| 277 // Given a path in NT native form ("\Device\HarddiskVolumeXX\..."), |
| 278 // return in |drive_letter_path| the equivalent path that starts with |
| 279 // a drive letter ("C:\..."). Return false if no such path exists. |
| 280 BASE_EXPORT bool DevicePathToDriveLetterPath(const FilePath& device_path, |
| 281 FilePath* drive_letter_path); |
| 282 |
| 283 // Given an existing file in |path|, set |real_path| to the path |
| 284 // in native NT format, of the form "\Device\HarddiskVolumeXX\..". |
| 285 // Returns false if the path can not be found. Empty files cannot |
| 286 // be resolved with this function. |
| 287 BASE_EXPORT bool NormalizeToNativeFilePath(const FilePath& path, |
| 288 FilePath* nt_path); |
| 289 #endif |
| 290 |
| 291 // This function will return if the given file is a symlink or not. |
| 292 BASE_EXPORT bool IsLink(const FilePath& file_path); |
| 293 |
| 294 // Returns information about the given file path. |
| 295 BASE_EXPORT bool GetFileInfo(const FilePath& file_path, PlatformFileInfo* info); |
| 296 |
275 } // namespace base | 297 } // namespace base |
276 | 298 |
277 // ----------------------------------------------------------------------------- | 299 // ----------------------------------------------------------------------------- |
278 | 300 |
279 namespace file_util { | 301 namespace file_util { |
280 | 302 |
281 #if defined(OS_WIN) | |
282 | |
283 // Given a path in NT native form ("\Device\HarddiskVolumeXX\..."), | |
284 // return in |drive_letter_path| the equivalent path that starts with | |
285 // a drive letter ("C:\..."). Return false if no such path exists. | |
286 BASE_EXPORT bool DevicePathToDriveLetterPath(const base::FilePath& device_path, | |
287 base::FilePath* drive_letter_path); | |
288 | |
289 // Given an existing file in |path|, set |real_path| to the path | |
290 // in native NT format, of the form "\Device\HarddiskVolumeXX\..". | |
291 // Returns false if the path can not be found. Empty files cannot | |
292 // be resolved with this function. | |
293 BASE_EXPORT bool NormalizeToNativeFilePath(const base::FilePath& path, | |
294 base::FilePath* nt_path); | |
295 #endif | |
296 | |
297 // This function will return if the given file is a symlink or not. | |
298 BASE_EXPORT bool IsLink(const base::FilePath& file_path); | |
299 | |
300 // Returns information about the given file path. | |
301 BASE_EXPORT bool GetFileInfo(const base::FilePath& file_path, | |
302 base::PlatformFileInfo* info); | |
303 | |
304 // Sets the time of the last access and the time of the last modification. | 303 // Sets the time of the last access and the time of the last modification. |
305 BASE_EXPORT bool TouchFile(const base::FilePath& path, | 304 BASE_EXPORT bool TouchFile(const base::FilePath& path, |
306 const base::Time& last_accessed, | 305 const base::Time& last_accessed, |
307 const base::Time& last_modified); | 306 const base::Time& last_modified); |
308 | 307 |
309 // Set the time of the last modification. Useful for unit tests. | 308 // Set the time of the last modification. Useful for unit tests. |
310 BASE_EXPORT bool SetLastModifiedTime(const base::FilePath& path, | 309 BASE_EXPORT bool SetLastModifiedTime(const base::FilePath& path, |
311 const base::Time& last_modified); | 310 const base::Time& last_modified); |
312 | 311 |
313 #if defined(OS_POSIX) | 312 #if defined(OS_POSIX) |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 // This function simulates Move(), but unlike Move() it works across volumes. | 465 // This function simulates Move(), but unlike Move() it works across volumes. |
467 // This function is not transactional. | 466 // This function is not transactional. |
468 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, | 467 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, |
469 const FilePath& to_path); | 468 const FilePath& to_path); |
470 #endif // defined(OS_WIN) | 469 #endif // defined(OS_WIN) |
471 | 470 |
472 } // namespace internal | 471 } // namespace internal |
473 } // namespace base | 472 } // namespace base |
474 | 473 |
475 #endif // BASE_FILE_UTIL_H_ | 474 #endif // BASE_FILE_UTIL_H_ |
OLD | NEW |