summaryrefslogtreecommitdiffstats
path: root/base/file_util_win.cc
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-28 06:50:36 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-28 06:50:36 +0000
commit6faa0e0d23ca6fc27ae603063ce23eb018a670cd (patch)
treece8256337ad0632cd3cdb797394ffeb1500e9280 /base/file_util_win.cc
parent7b441021461106603e4b7769305b8fce7db17294 (diff)
downloadchromium_src-6faa0e0d23ca6fc27ae603063ce23eb018a670cd.zip
chromium_src-6faa0e0d23ca6fc27ae603063ce23eb018a670cd.tar.gz
chromium_src-6faa0e0d23ca6fc27ae603063ce23eb018a670cd.tar.bz2
ImportantFileWriter
Introducing a class for writing important files, preventing their corruption during writing. Switched PrefService to use it. Other classes will be switched in future changesets. TEST=This may affect things using preferences. Make sure that changes in preferences don't get lost, and that you don't get excessive disk activity when changing preferences. http://crbug.com/10618 Review URL: http://codereview.chromium.org/83001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14717 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util_win.cc')
-rw-r--r--base/file_util_win.cc20
1 files changed, 12 insertions, 8 deletions
diff --git a/base/file_util_win.cc b/base/file_util_win.cc
index 8b3d4f5..8964fbf 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,