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

Unified Diff: base/file_util_win.cc

Issue 184563006: Move WriteFile and WriteFileDescriptor from file_util to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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/file_util_unittest.cc ('k') | base/files/file_path_watcher_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util_win.cc
diff --git a/base/file_util_win.cc b/base/file_util_win.cc
index e7aadc218c4a765ad921f70e0b47f7aa71296328..58e02dcc36abec7d1495b361db9f556d63c439a6 100644
--- a/base/file_util_win.cc
+++ b/base/file_util_win.cc
@@ -599,23 +599,8 @@ int ReadFile(const FilePath& filename, char* data, int size) {
return -1;
}
-} // namespace base
-
-// -----------------------------------------------------------------------------
-
-namespace file_util {
-
-using base::DirectoryExists;
-using base::FilePath;
-using base::kFileShareAll;
-
-FILE* OpenFile(const std::string& filename, const char* mode) {
- base::ThreadRestrictions::AssertIOAllowed();
- return _fsopen(filename.c_str(), mode, _SH_DENYNO);
-}
-
int WriteFile(const FilePath& filename, const char* data, int size) {
- base::ThreadRestrictions::AssertIOAllowed();
+ ThreadRestrictions::AssertIOAllowed();
base::win::ScopedHandle file(CreateFile(filename.value().c_str(),
GENERIC_WRITE,
0,
@@ -625,7 +610,7 @@ int WriteFile(const FilePath& filename, const char* data, int size) {
NULL));
if (!file) {
DLOG_GETLASTERROR(WARNING) << "CreateFile failed for path "
- << filename.value();
+ << UTF16ToUTF8(filename.value());
return -1;
}
@@ -636,16 +621,31 @@ int WriteFile(const FilePath& filename, const char* data, int size) {
if (!result) {
// WriteFile failed.
- DLOG_GETLASTERROR(WARNING) << "writing file " << filename.value()
- << " failed";
+ DLOG_GETLASTERROR(WARNING) << "writing file "
+ << UTF16ToUTF8(filename.value()) << " failed";
} else {
// Didn't write all the bytes.
DLOG(WARNING) << "wrote" << written << " bytes to "
- << filename.value() << " expected " << size;
+ << UTF16ToUTF8(filename.value()) << " expected " << size;
}
return -1;
}
+} // namespace base
+
+// -----------------------------------------------------------------------------
+
+namespace file_util {
+
+using base::DirectoryExists;
+using base::FilePath;
+using base::kFileShareAll;
+
+FILE* OpenFile(const std::string& filename, const char* mode) {
+ base::ThreadRestrictions::AssertIOAllowed();
+ return _fsopen(filename.c_str(), mode, _SH_DENYNO);
+}
+
int AppendToFile(const FilePath& filename, const char* data, int size) {
base::ThreadRestrictions::AssertIOAllowed();
base::win::ScopedHandle file(CreateFile(filename.value().c_str(),
« no previous file with comments | « base/file_util_unittest.cc ('k') | base/files/file_path_watcher_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698