| 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 #include "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 | 6 |
| 7 #include <dirent.h> | 7 #include <dirent.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <fcntl.h> | 9 #include <fcntl.h> |
| 10 #include <fnmatch.h> | 10 #include <fnmatch.h> |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 if (rename(from_path.value().c_str(), to_path.value().c_str()) == 0) | 225 if (rename(from_path.value().c_str(), to_path.value().c_str()) == 0) |
| 226 return true; | 226 return true; |
| 227 | 227 |
| 228 if (!CopyDirectory(from_path, to_path, true)) | 228 if (!CopyDirectory(from_path, to_path, true)) |
| 229 return false; | 229 return false; |
| 230 | 230 |
| 231 Delete(from_path, true); | 231 Delete(from_path, true); |
| 232 return true; | 232 return true; |
| 233 } | 233 } |
| 234 | 234 |
| 235 bool ReplaceFile(const FilePath& from_path, const FilePath& to_path) { | 235 bool ReplaceFile(const FilePath& from_path, const FilePath& to_path, |
| 236 base::PlatformFileError* error) { |
| 236 base::ThreadRestrictions::AssertIOAllowed(); | 237 base::ThreadRestrictions::AssertIOAllowed(); |
| 237 return (rename(from_path.value().c_str(), to_path.value().c_str()) == 0); | 238 if (rename(from_path.value().c_str(), to_path.value().c_str()) == 0) |
| 239 return true; |
| 240 if (error) |
| 241 *error = base::ErrnoToPlatformFileError(errno); |
| 242 return false; |
| 238 } | 243 } |
| 239 | 244 |
| 240 bool CopyDirectory(const FilePath& from_path, | 245 bool CopyDirectory(const FilePath& from_path, |
| 241 const FilePath& to_path, | 246 const FilePath& to_path, |
| 242 bool recursive) { | 247 bool recursive) { |
| 243 base::ThreadRestrictions::AssertIOAllowed(); | 248 base::ThreadRestrictions::AssertIOAllowed(); |
| 244 // Some old callers of CopyDirectory want it to support wildcards. | 249 // Some old callers of CopyDirectory want it to support wildcards. |
| 245 // After some discussion, we decided to fix those callers. | 250 // After some discussion, we decided to fix those callers. |
| 246 // Break loudly here if anyone tries to do this. | 251 // Break loudly here if anyone tries to do this. |
| 247 // TODO(evanm): remove this once we're sure it's ok. | 252 // TODO(evanm): remove this once we're sure it's ok. |
| (...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 kFileSystemRoot, path, kRootUid, allowed_group_ids); | 1066 kFileSystemRoot, path, kRootUid, allowed_group_ids); |
| 1062 } | 1067 } |
| 1063 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 1068 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
| 1064 | 1069 |
| 1065 int GetMaximumPathComponentLength(const FilePath& path) { | 1070 int GetMaximumPathComponentLength(const FilePath& path) { |
| 1066 base::ThreadRestrictions::AssertIOAllowed(); | 1071 base::ThreadRestrictions::AssertIOAllowed(); |
| 1067 return pathconf(path.value().c_str(), _PC_NAME_MAX); | 1072 return pathconf(path.value().c_str(), _PC_NAME_MAX); |
| 1068 } | 1073 } |
| 1069 | 1074 |
| 1070 } // namespace file_util | 1075 } // namespace file_util |
| OLD | NEW |