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

Unified Diff: base/file_util_win.cc

Issue 83001: ImportantFileWriter (Closed)
Patch Set: share more code Created 11 years, 8 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_posix.cc ('k') | chrome/browser/bookmarks/bookmark_utils.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 8b3d4f561481374692da8fa55e5d17a543e332ae..8964fbfa8310ff72911684844131a076a45eba44 100644
--- a/base/file_util_win.cc
+++ b/base/file_util_win.cc
@@ -446,20 +446,24 @@ bool CreateTemporaryFileName(FilePath* path) {
return false;
}
+FILE* CreateAndOpenTemporaryShmemFile(FilePath* path) {
+ return CreateAndOpenTemporaryFile(path);
+}
+
// On POSIX we have semantics to create and open a temporary file
// atomically.
// TODO(jrg): is there equivalent call to use on Windows instead of
// going 2-step?
-FILE* CreateAndOpenTemporaryFile(FilePath* path) {
-
- if (!CreateTemporaryFileName(path)) {
+FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir, FilePath* path) {
+ std::wstring wstring_path;
+ if (!CreateTemporaryFileNameInDir(dir.value(), &wstring_path)) {
return NULL;
}
- return OpenFile(*path, "w+");
-}
-
-FILE* CreateAndOpenTemporaryShmemFile(FilePath* path) {
- return CreateAndOpenTemporaryFile(path);
+ *path = FilePath(wstring_path);
+ // Open file in binary mode, to avoid problems with fwrite. On Windows
+ // it replaces \n's with \r\n's, which may surprise you.
+ // Reference: http://msdn.microsoft.com/en-us/library/h9t88zwz(VS.71).aspx
+ return OpenFile(*path, "wb+");
}
bool CreateTemporaryFileNameInDir(const std::wstring& dir,
« no previous file with comments | « base/file_util_posix.cc ('k') | chrome/browser/bookmarks/bookmark_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698