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

Side by Side Diff: base/file_util.h

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 | « no previous file | base/file_util.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 // This file contains utility functions for dealing with the local 5 // This file contains utility functions for dealing with the local
6 // filesystem. 6 // filesystem.
7 7
8 #ifndef BASE_FILE_UTIL_H_ 8 #ifndef BASE_FILE_UTIL_H_
9 #define BASE_FILE_UTIL_H_ 9 #define BASE_FILE_UTIL_H_
10 10
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 // Same as Move but allows paths with traversal components. 95 // Same as Move but allows paths with traversal components.
96 // Use only with extreme care. 96 // Use only with extreme care.
97 BASE_EXPORT bool MoveUnsafe(const base::FilePath& from_path, 97 BASE_EXPORT bool MoveUnsafe(const base::FilePath& from_path,
98 const base::FilePath& to_path); 98 const base::FilePath& to_path);
99 99
100 // Renames file |from_path| to |to_path|. Both paths must be on the same 100 // Renames file |from_path| to |to_path|. Both paths must be on the same
101 // volume, or the function will fail. Destination file will be created 101 // volume, or the function will fail. Destination file will be created
102 // if it doesn't exist. Prefer this function over Move when dealing with 102 // if it doesn't exist. Prefer this function over Move when dealing with
103 // temporary files. On Windows it preserves attributes of the target file. 103 // temporary files. On Windows it preserves attributes of the target file.
104 // Returns true on success. 104 // Returns true on success, leaving *error unchanged.
105 // Returns false on failure and sets *error appropriately, if it is non-NULL.
106 BASE_EXPORT bool ReplaceFileAndGetError(const base::FilePath& from_path,
107 const base::FilePath& to_path,
108 base::PlatformFileError* error);
109
110 // Backward-compatible convenience method for the above.
105 BASE_EXPORT bool ReplaceFile(const base::FilePath& from_path, 111 BASE_EXPORT bool ReplaceFile(const base::FilePath& from_path,
106 const base::FilePath& to_path); 112 const base::FilePath& to_path);
107 113
108 // Copies a single file. Use CopyDirectory to copy directories. 114 // Copies a single file. Use CopyDirectory to copy directories.
109 // This function fails if either path contains traversal components ('..'). 115 // This function fails if either path contains traversal components ('..').
110 BASE_EXPORT bool CopyFile(const base::FilePath& from_path, 116 BASE_EXPORT bool CopyFile(const base::FilePath& from_path,
111 const base::FilePath& to_path); 117 const base::FilePath& to_path);
112 118
113 // Same as CopyFile but allows paths with traversal components. 119 // Same as CopyFile but allows paths with traversal components.
114 // Use only with extreme care. 120 // Use only with extreme care.
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 552
547 // Attempts determine the FileSystemType for |path|. 553 // Attempts determine the FileSystemType for |path|.
548 // Returns false if |path| doesn't exist. 554 // Returns false if |path| doesn't exist.
549 BASE_EXPORT bool GetFileSystemType(const base::FilePath& path, 555 BASE_EXPORT bool GetFileSystemType(const base::FilePath& path,
550 FileSystemType* type); 556 FileSystemType* type);
551 #endif 557 #endif
552 558
553 } // namespace file_util 559 } // namespace file_util
554 560
555 #endif // BASE_FILE_UTIL_H_ 561 #endif // BASE_FILE_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | base/file_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698