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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // function can result in I/O so it can be slow. | 50 // function can result in I/O so it can be slow. |
51 BASE_EXPORT FilePath MakeAbsoluteFilePath(const FilePath& input); | 51 BASE_EXPORT FilePath MakeAbsoluteFilePath(const FilePath& input); |
52 | 52 |
53 // Returns the total number of bytes used by all the files under |root_path|. | 53 // Returns the total number of bytes used by all the files under |root_path|. |
54 // If the path does not exist the function returns 0. | 54 // If the path does not exist the function returns 0. |
55 // | 55 // |
56 // This function is implemented using the FileEnumerator class so it is not | 56 // This function is implemented using the FileEnumerator class so it is not |
57 // particularly speedy in any platform. | 57 // particularly speedy in any platform. |
58 BASE_EXPORT int64 ComputeDirectorySize(const FilePath& root_path); | 58 BASE_EXPORT int64 ComputeDirectorySize(const FilePath& root_path); |
59 | 59 |
60 } // namespace base | |
61 | |
62 namespace file_util { | |
63 | |
64 // Deletes the given path, whether it's a file or a directory. | 60 // Deletes the given path, whether it's a file or a directory. |
65 // If it's a directory, it's perfectly happy to delete all of the | 61 // If it's a directory, it's perfectly happy to delete all of the |
66 // directory's contents. Passing true to recursive deletes | 62 // directory's contents. Passing true to recursive deletes |
67 // subdirectories and their contents as well. | 63 // subdirectories and their contents as well. |
68 // Returns true if successful, false otherwise. It is considered successful | 64 // Returns true if successful, false otherwise. It is considered successful |
69 // to attempt to delete a file that does not exist. | 65 // to attempt to delete a file that does not exist. |
70 // | 66 // |
71 // In posix environment and if |path| is a symbolic link, this deletes only | 67 // In posix environment and if |path| is a symbolic link, this deletes only |
72 // the symlink. (even if the symlink points to a non-existent file) | 68 // the symlink. (even if the symlink points to a non-existent file) |
73 // | 69 // |
74 // WARNING: USING THIS WITH recursive==true IS EQUIVALENT | 70 // WARNING: USING THIS WITH recursive==true IS EQUIVALENT |
75 // TO "rm -rf", SO USE WITH CAUTION. | 71 // TO "rm -rf", SO USE WITH CAUTION. |
76 BASE_EXPORT bool Delete(const base::FilePath& path, bool recursive); | 72 BASE_EXPORT bool Delete(const FilePath& path, bool recursive); |
| 73 |
| 74 } // namespace base |
| 75 |
| 76 // ----------------------------------------------------------------------------- |
| 77 |
| 78 namespace file_util { |
77 | 79 |
78 #if defined(OS_WIN) | 80 #if defined(OS_WIN) |
79 // Schedules to delete the given path, whether it's a file or a directory, until | 81 // Schedules to delete the given path, whether it's a file or a directory, until |
80 // the operating system is restarted. | 82 // the operating system is restarted. |
81 // Note: | 83 // Note: |
82 // 1) The file/directory to be deleted should exist in a temp folder. | 84 // 1) The file/directory to be deleted should exist in a temp folder. |
83 // 2) The directory to be deleted must be empty. | 85 // 2) The directory to be deleted must be empty. |
84 BASE_EXPORT bool DeleteAfterReboot(const base::FilePath& path); | 86 BASE_EXPORT bool DeleteAfterReboot(const base::FilePath& path); |
85 #endif | 87 #endif |
86 | 88 |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 | 453 |
452 // Attempts determine the FileSystemType for |path|. | 454 // Attempts determine the FileSystemType for |path|. |
453 // Returns false if |path| doesn't exist. | 455 // Returns false if |path| doesn't exist. |
454 BASE_EXPORT bool GetFileSystemType(const base::FilePath& path, | 456 BASE_EXPORT bool GetFileSystemType(const base::FilePath& path, |
455 FileSystemType* type); | 457 FileSystemType* type); |
456 #endif | 458 #endif |
457 | 459 |
458 } // namespace file_util | 460 } // namespace file_util |
459 | 461 |
460 #endif // BASE_FILE_UTIL_H_ | 462 #endif // BASE_FILE_UTIL_H_ |
OLD | NEW |