OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 // file name component. Any leading or trailing whitespace in 'file_name' is | 130 // file name component. Any leading or trailing whitespace in 'file_name' is |
131 // removed. | 131 // removed. |
132 // Example: | 132 // Example: |
133 // file_name == "bad:file*name?.txt", changed to: "bad-file-name-.txt" when | 133 // file_name == "bad:file*name?.txt", changed to: "bad-file-name-.txt" when |
134 // 'replace_char' is '-'. | 134 // 'replace_char' is '-'. |
135 void ReplaceIllegalCharacters(std::wstring* file_name, int replace_char); | 135 void ReplaceIllegalCharacters(std::wstring* file_name, int replace_char); |
136 | 136 |
137 //----------------------------------------------------------------------------- | 137 //----------------------------------------------------------------------------- |
138 // Functions that involve filesystem access or modification: | 138 // Functions that involve filesystem access or modification: |
139 | 139 |
140 #if defined(OS_WIN) | |
141 // Returns the number of files matching the current path that were | |
142 // created on or after the given |file_time|. Doesn't count ".." or ".". | 140 // created on or after the given |file_time|. Doesn't count ".." or ".". |
| 141 // |
| 142 // Note for POSIX environments: a file created before |file_time| |
| 143 // can be mis-detected as a newer file due to low precision of |
| 144 // timestmap of file creation time. If you need to avoid such |
| 145 // mis-detection perfectly, you should wait one second before |
| 146 // obtaining |file_time|. |
143 int CountFilesCreatedAfter(const FilePath& path, | 147 int CountFilesCreatedAfter(const FilePath& path, |
144 const base::Time& file_time); | 148 const base::Time& file_time); |
145 #endif // defined(OS_WIN) | |
146 | 149 |
147 // Deletes the given path, whether it's a file or a directory. | 150 // Deletes the given path, whether it's a file or a directory. |
148 // If it's a directory, it's perfectly happy to delete all of the | 151 // If it's a directory, it's perfectly happy to delete all of the |
149 // directory's contents. Passing true to recursive deletes | 152 // directory's contents. Passing true to recursive deletes |
150 // subdirectories and their contents as well. | 153 // subdirectories and their contents as well. |
151 // Returns true if successful, false otherwise. | 154 // Returns true if successful, false otherwise. |
152 // | 155 // |
153 // WARNING: USING THIS WITH recursive==true IS EQUIVALENT | 156 // WARNING: USING THIS WITH recursive==true IS EQUIVALENT |
154 // TO "rm -rf", SO USE WITH CAUTION. | 157 // TO "rm -rf", SO USE WITH CAUTION. |
155 bool Delete(const FilePath& path, bool recursive); | 158 bool Delete(const FilePath& path, bool recursive); |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 | 511 |
509 // Renames a file using the SHFileOperation API to ensure that the target file | 512 // Renames a file using the SHFileOperation API to ensure that the target file |
510 // gets the correct default security descriptor in the new path. | 513 // gets the correct default security descriptor in the new path. |
511 bool RenameFileAndResetSecurityDescriptor( | 514 bool RenameFileAndResetSecurityDescriptor( |
512 const FilePath& source_file_path, | 515 const FilePath& source_file_path, |
513 const FilePath& target_file_path); | 516 const FilePath& target_file_path); |
514 | 517 |
515 } // namespace file_util | 518 } // namespace file_util |
516 | 519 |
517 #endif // BASE_FILE_UTIL_H_ | 520 #endif // BASE_FILE_UTIL_H_ |
OLD | NEW |