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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // TO "rm -rf", SO USE WITH CAUTION. | 126 // TO "rm -rf", SO USE WITH CAUTION. |
127 bool Delete(const FilePath& path, bool recursive); | 127 bool Delete(const FilePath& path, bool recursive); |
128 // Deprecated temporary compatibility function. | 128 // Deprecated temporary compatibility function. |
129 bool Delete(const std::wstring& path, bool recursive); | 129 bool Delete(const std::wstring& path, bool recursive); |
130 | 130 |
131 // Moves the given path, whether it's a file or a directory. | 131 // Moves the given path, whether it's a file or a directory. |
132 // If a simple rename is not possible, such as in the case where the paths are | 132 // If a simple rename is not possible, such as in the case where the paths are |
133 // on different volumes, this will attempt to copy and delete. Returns | 133 // on different volumes, this will attempt to copy and delete. Returns |
134 // true for success. | 134 // true for success. |
135 bool Move(const FilePath& from_path, const FilePath& to_path); | 135 bool Move(const FilePath& from_path, const FilePath& to_path); |
| 136 // Deprecated temporary compatibility function. |
| 137 bool Move(const std::wstring& from_path, const std::wstring& to_path); |
136 | 138 |
137 // Renames file |from_path| to |to_path|. Both paths must be on the same | 139 // Renames file |from_path| to |to_path|. Both paths must be on the same |
138 // volume, or the function will fail. Destination file will be created | 140 // volume, or the function will fail. Destination file will be created |
139 // if it doesn't exist. Prefer this function over Move when dealing with | 141 // if it doesn't exist. Prefer this function over Move when dealing with |
140 // temporary files. On Windows it preserves attributes of the target file. | 142 // temporary files. On Windows it preserves attributes of the target file. |
141 // Returns true on success. | 143 // Returns true on success. |
142 bool ReplaceFile(const FilePath& from_path, const FilePath& to_path); | 144 bool ReplaceFile(const FilePath& from_path, const FilePath& to_path); |
143 | 145 |
144 // Copies a single file. Use CopyDirectory to copy directories. | 146 // Copies a single file. Use CopyDirectory to copy directories. |
145 bool CopyFile(const FilePath& from_path, const FilePath& to_path); | 147 bool CopyFile(const FilePath& from_path, const FilePath& to_path); |
| 148 // Deprecated temporary compatibility function. |
| 149 bool CopyFile(const std::wstring& from_path, const std::wstring& to_path); |
146 | 150 |
147 // Copies the given path, and optionally all subdirectories and their contents | 151 // Copies the given path, and optionally all subdirectories and their contents |
148 // as well. | 152 // as well. |
149 // If there are files existing under to_path, always overwrite. | 153 // If there are files existing under to_path, always overwrite. |
150 // Returns true if successful, false otherwise. | 154 // Returns true if successful, false otherwise. |
151 // Don't use wildcards on the names, it may stop working without notice. | 155 // Don't use wildcards on the names, it may stop working without notice. |
152 // | 156 // |
153 // If you only need to copy a file use CopyFile, it's faster. | 157 // If you only need to copy a file use CopyFile, it's faster. |
154 bool CopyDirectory(const FilePath& from_path, const FilePath& to_path, | 158 bool CopyDirectory(const FilePath& from_path, const FilePath& to_path, |
155 bool recursive); | 159 bool recursive); |
156 // Deprecated temporary compatibility function. | 160 // Deprecated temporary compatibility function. |
157 bool CopyDirectory(const std::wstring& from_path, const std::wstring& to_path, | 161 bool CopyDirectory(const std::wstring& from_path, const std::wstring& to_path, |
158 bool recursive); | 162 bool recursive); |
159 | 163 |
160 // Returns true if the given path exists on the local filesystem, | 164 // Returns true if the given path exists on the local filesystem, |
161 // false otherwise. | 165 // false otherwise. |
162 bool PathExists(const FilePath& path); | 166 bool PathExists(const FilePath& path); |
| 167 // Deprecated temporary compatibility function. |
| 168 bool PathExists(const std::wstring& path); |
163 | 169 |
164 // Returns true if the given path is writable by the user, false otherwise. | 170 // Returns true if the given path is writable by the user, false otherwise. |
165 bool PathIsWritable(const FilePath& path); | 171 bool PathIsWritable(const FilePath& path); |
166 | 172 |
167 // Returns true if the given path exists and is a directory, false otherwise. | 173 // Returns true if the given path exists and is a directory, false otherwise. |
168 bool DirectoryExists(const FilePath& path); | 174 bool DirectoryExists(const FilePath& path); |
| 175 // Deprecated temporary compatibility function. |
| 176 bool DirectoryExists(const std::wstring& path); |
169 | 177 |
170 #if defined(OS_WIN) | 178 #if defined(OS_WIN) |
171 // Gets the creation time of the given file (expressed in the local timezone), | 179 // Gets the creation time of the given file (expressed in the local timezone), |
172 // and returns it via the creation_time parameter. Returns true if successful, | 180 // and returns it via the creation_time parameter. Returns true if successful, |
173 // false otherwise. | 181 // false otherwise. |
174 bool GetFileCreationLocalTime(const std::wstring& filename, | 182 bool GetFileCreationLocalTime(const std::wstring& filename, |
175 LPSYSTEMTIME creation_time); | 183 LPSYSTEMTIME creation_time); |
176 | 184 |
177 // Same as above, but takes a previously-opened file handle instead of a name. | 185 // Same as above, but takes a previously-opened file handle instead of a name. |
178 bool GetFileCreationLocalTimeFromHandle(HANDLE file_handle, | 186 bool GetFileCreationLocalTimeFromHandle(HANDLE file_handle, |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 | 529 |
522 // Renames a file using the SHFileOperation API to ensure that the target file | 530 // Renames a file using the SHFileOperation API to ensure that the target file |
523 // gets the correct default security descriptor in the new path. | 531 // gets the correct default security descriptor in the new path. |
524 bool RenameFileAndResetSecurityDescriptor( | 532 bool RenameFileAndResetSecurityDescriptor( |
525 const FilePath& source_file_path, | 533 const FilePath& source_file_path, |
526 const FilePath& target_file_path); | 534 const FilePath& target_file_path); |
527 | 535 |
528 } // namespace file_util | 536 } // namespace file_util |
529 | 537 |
530 #endif // BASE_FILE_UTIL_H_ | 538 #endif // BASE_FILE_UTIL_H_ |
OLD | NEW |