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

Side by Side Diff: base/file_util.cc

Issue 14886003: Make base:ReplaceFile return an informative error. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ToT Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/file_util.h ('k') | base/file_util_posix.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "base/file_util.h" 5 #include "base/file_util.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <io.h> 8 #include <io.h>
9 #endif 9 #endif
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 value.insert(last_dot, suffix); 57 value.insert(last_dot, suffix);
58 } 58 }
59 59
60 bool Move(const FilePath& from_path, const FilePath& to_path) { 60 bool Move(const FilePath& from_path, const FilePath& to_path) {
61 if (from_path.ReferencesParent() || to_path.ReferencesParent()) 61 if (from_path.ReferencesParent() || to_path.ReferencesParent())
62 return false; 62 return false;
63 return MoveUnsafe(from_path, to_path); 63 return MoveUnsafe(from_path, to_path);
64 } 64 }
65 65
66 bool ReplaceFile(const base::FilePath& from_path,
67 const base::FilePath& to_path) {
68 return ReplaceFileAndGetError(from_path, to_path, NULL);
69 }
70
66 bool CopyFile(const FilePath& from_path, const FilePath& to_path) { 71 bool CopyFile(const FilePath& from_path, const FilePath& to_path) {
67 if (from_path.ReferencesParent() || to_path.ReferencesParent()) 72 if (from_path.ReferencesParent() || to_path.ReferencesParent())
68 return false; 73 return false;
69 return CopyFileUnsafe(from_path, to_path); 74 return CopyFileUnsafe(from_path, to_path);
70 } 75 }
71 76
72 bool ContentsEqual(const FilePath& filename1, const FilePath& filename2) { 77 bool ContentsEqual(const FilePath& filename1, const FilePath& filename2) {
73 // We open the file in binary format even if they are text files because 78 // We open the file in binary format even if they are text files because
74 // we are just comparing that bytes are exactly same in both files and not 79 // we are just comparing that bytes are exactly same in both files and not
75 // doing anything smart with text formatting. 80 // doing anything smart with text formatting.
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 // Note: the main logic is in file_util_<platform>.cc 287 // Note: the main logic is in file_util_<platform>.cc
283 288
284 bool FileEnumerator::ShouldSkip(const FilePath& path) { 289 bool FileEnumerator::ShouldSkip(const FilePath& path) {
285 FilePath::StringType basename = path.BaseName().value(); 290 FilePath::StringType basename = path.BaseName().value();
286 return basename == FILE_PATH_LITERAL(".") || 291 return basename == FILE_PATH_LITERAL(".") ||
287 (basename == FILE_PATH_LITERAL("..") && 292 (basename == FILE_PATH_LITERAL("..") &&
288 !(INCLUDE_DOT_DOT & file_type_)); 293 !(INCLUDE_DOT_DOT & file_type_));
289 } 294 }
290 295
291 } // namespace 296 } // namespace
OLDNEW
« no previous file with comments | « base/file_util.h ('k') | base/file_util_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698