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

Unified Diff: base/files/file_util_win.cc

Issue 614893004: Refactor AppendToFile and WriteFileDescriptor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nits Created 6 years, 2 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_unittest.cc ('k') | base/sync_socket_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_util_win.cc
diff --git a/base/files/file_util_win.cc b/base/files/file_util_win.cc
index b58619192378d50bab86a791dcdce665cf7a0545..733c32c27da220e47d4cab076a89a08430ad6b09 100644
--- a/base/files/file_util_win.cc
+++ b/base/files/file_util_win.cc
@@ -644,7 +644,7 @@ int WriteFile(const FilePath& filename, const char* data, int size) {
return -1;
}
-int AppendToFile(const FilePath& filename, const char* data, int size) {
+bool AppendToFile(const FilePath& filename, const char* data, int size) {
ThreadRestrictions::AssertIOAllowed();
base::win::ScopedHandle file(CreateFile(filename.value().c_str(),
FILE_APPEND_DATA,
@@ -654,26 +654,24 @@ int AppendToFile(const FilePath& filename, const char* data, int size) {
0,
NULL));
if (!file.IsValid()) {
- DPLOG(WARNING) << "CreateFile failed for path "
- << UTF16ToUTF8(filename.value());
- return -1;
+ VPLOG(1) << "CreateFile failed for path " << UTF16ToUTF8(filename.value());
+ return false;
}
DWORD written;
BOOL result = ::WriteFile(file.Get(), data, size, &written, NULL);
if (result && static_cast<int>(written) == size)
- return written;
+ return true;
if (!result) {
// WriteFile failed.
- DPLOG(WARNING) << "writing file " << UTF16ToUTF8(filename.value())
- << " failed";
+ VPLOG(1) << "Writing file " << UTF16ToUTF8(filename.value()) << " failed";
} else {
// Didn't write all the bytes.
- DLOG(WARNING) << "wrote" << written << " bytes to "
- << UTF16ToUTF8(filename.value()) << " expected " << size;
+ VPLOG(1) << "Only wrote " << written << " out of " << size << " byte(s) to "
+ << UTF16ToUTF8(filename.value());
}
- return -1;
+ return false;
}
// Gets the current working directory for the process.
« no previous file with comments | « base/files/file_util_unittest.cc ('k') | base/sync_socket_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698