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

Unified Diff: base/files/important_file_writer.cc

Issue 101143006: Convert base::file_util to use File instead of PlatformFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove base:: Created 6 years, 11 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
« no previous file with comments | « base/files/file_util_proxy_unittest.cc ('k') | base/nix/mime_util_xdg.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/important_file_writer.cc
diff --git a/base/files/important_file_writer.cc b/base/files/important_file_writer.cc
index 261c98772e5e67c27811f495ca2dd5c66cba87d7..9cbbd736e5baa5b53c2577909ffad724f30e89d4 100644
--- a/base/files/important_file_writer.cc
+++ b/base/files/important_file_writer.cc
@@ -17,6 +17,7 @@
#include "base/bind.h"
#include "base/critical_closure.h"
#include "base/file_util.h"
+#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
@@ -63,25 +64,18 @@ bool ImportantFileWriter::WriteFileAtomically(const FilePath& path,
return false;
}
- int flags = PLATFORM_FILE_OPEN | PLATFORM_FILE_WRITE;
- PlatformFile tmp_file =
- CreatePlatformFile(tmp_file_path, flags, NULL, NULL);
- if (tmp_file == kInvalidPlatformFileValue) {
+ File tmp_file(tmp_file_path, File::FLAG_OPEN | File::FLAG_WRITE);
+ if (!tmp_file.IsValid()) {
LogFailure(path, FAILED_OPENING, "could not open temporary file");
return false;
}
// If this happens in the wild something really bad is going on.
CHECK_LE(data.length(), static_cast<size_t>(kint32max));
- int bytes_written = WritePlatformFile(
- tmp_file, 0, data.data(), static_cast<int>(data.length()));
- FlushPlatformFile(tmp_file); // Ignore return value.
-
- if (!ClosePlatformFile(tmp_file)) {
- LogFailure(path, FAILED_CLOSING, "failed to close temporary file");
- base::DeleteFile(tmp_file_path, false);
- return false;
- }
+ int bytes_written = tmp_file.Write(0, data.data(),
+ static_cast<int>(data.length()));
+ tmp_file.Flush(); // Ignore return value.
+ tmp_file.Close();
if (bytes_written < static_cast<int>(data.length())) {
LogFailure(path, FAILED_WRITING, "error writing, bytes_written=" +
« no previous file with comments | « base/files/file_util_proxy_unittest.cc ('k') | base/nix/mime_util_xdg.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698