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

Side by Side Diff: base/files/important_file_writer.cc

Issue 99923002: Move temp file functions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/files/file_util_proxy.cc ('k') | base/files/scoped_temp_dir.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if defined _MSC_VER && _MSC_VER == 1800 5 #if defined _MSC_VER && _MSC_VER == 1800
6 // TODO(scottmg): Internal errors on VS2013 RC in LTCG. This should be removed 6 // TODO(scottmg): Internal errors on VS2013 RC in LTCG. This should be removed
7 // after RTM. http://crbug.com/288948 7 // after RTM. http://crbug.com/288948
8 #pragma optimize("", off) 8 #pragma optimize("", off)
9 #endif 9 #endif
10 10
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } // namespace 51 } // namespace
52 52
53 // static 53 // static
54 bool ImportantFileWriter::WriteFileAtomically(const FilePath& path, 54 bool ImportantFileWriter::WriteFileAtomically(const FilePath& path,
55 const std::string& data) { 55 const std::string& data) {
56 // Write the data to a temp file then rename to avoid data loss if we crash 56 // Write the data to a temp file then rename to avoid data loss if we crash
57 // while writing the file. Ensure that the temp file is on the same volume 57 // while writing the file. Ensure that the temp file is on the same volume
58 // as target file, so it can be moved in one step, and that the temp file 58 // as target file, so it can be moved in one step, and that the temp file
59 // is securely created. 59 // is securely created.
60 FilePath tmp_file_path; 60 FilePath tmp_file_path;
61 if (!file_util::CreateTemporaryFileInDir(path.DirName(), &tmp_file_path)) { 61 if (!base::CreateTemporaryFileInDir(path.DirName(), &tmp_file_path)) {
62 LogFailure(path, FAILED_CREATING, "could not create temporary file"); 62 LogFailure(path, FAILED_CREATING, "could not create temporary file");
63 return false; 63 return false;
64 } 64 }
65 65
66 int flags = PLATFORM_FILE_OPEN | PLATFORM_FILE_WRITE; 66 int flags = PLATFORM_FILE_OPEN | PLATFORM_FILE_WRITE;
67 PlatformFile tmp_file = 67 PlatformFile tmp_file =
68 CreatePlatformFile(tmp_file_path, flags, NULL, NULL); 68 CreatePlatformFile(tmp_file_path, flags, NULL, NULL);
69 if (tmp_file == kInvalidPlatformFileValue) { 69 if (tmp_file == kInvalidPlatformFileValue) {
70 LogFailure(path, FAILED_OPENING, "could not open temporary file"); 70 LogFailure(path, FAILED_OPENING, "could not open temporary file");
71 return false; 71 return false;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 if (serializer_->SerializeData(&data)) { 164 if (serializer_->SerializeData(&data)) {
165 WriteNow(data); 165 WriteNow(data);
166 } else { 166 } else {
167 DLOG(WARNING) << "failed to serialize data to be saved in " 167 DLOG(WARNING) << "failed to serialize data to be saved in "
168 << path_.value().c_str(); 168 << path_.value().c_str();
169 } 169 }
170 serializer_ = NULL; 170 serializer_ = NULL;
171 } 171 }
172 172
173 } // namespace base 173 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file_util_proxy.cc ('k') | base/files/scoped_temp_dir.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698