Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2752)

Unified Diff: base/file_util_posix.cc

Issue 14886003: Make base:ReplaceFile return an informative error. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: respond to comments Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/file_util_posix.cc
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index 8b368127410e091eb392cf440f2bd9c50a417acd..b3bb27d1e8a6a93aa454a122a93939757a6b818d 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -232,9 +232,14 @@ bool MoveUnsafe(const FilePath& from_path, const FilePath& to_path) {
return true;
}
-bool ReplaceFile(const FilePath& from_path, const FilePath& to_path) {
+bool ReplaceFile(const FilePath& from_path, const FilePath& to_path,
+ base::PlatformFileError* error) {
base::ThreadRestrictions::AssertIOAllowed();
- return (rename(from_path.value().c_str(), to_path.value().c_str()) == 0);
+ if (rename(from_path.value().c_str(), to_path.value().c_str()) == 0)
+ return true;
+ if (error)
+ *error = base::ErrnoToPlatformFileError(errno);
+ return false;
}
bool CopyDirectory(const FilePath& from_path,

Powered by Google App Engine
This is Rietveld 408576698