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