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

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: change comment 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..97919ffdf055a92254879400f247e3ad5b4949a4 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -232,9 +232,17 @@ 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) {
+ if (error)
+ *error = base::PLATFORM_FILE_OK;
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) {
+ if (error)
+ *error = base::ErrnoToPlatformFileError(errno);
+ return false;
+ }
+ return true;
jar (doing other things) 2013/05/07 01:12:36 nit: switch the order of the results around, and y
}
bool CopyDirectory(const FilePath& from_path,

Powered by Google App Engine
This is Rietveld 408576698