diff options
Diffstat (limited to 'base/file_util_win.cc')
-rw-r--r-- | base/file_util_win.cc | 20 |
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, |