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

Unified Diff: base/file_util_posix.cc

Issue 141273010: Make CopyDirectory() not copy the read only bit on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert change to CopyFileUnsafe Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/file_util.h ('k') | base/file_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util_posix.cc
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index 3f0ee0aef2efd54c583e3102e02e484cd9b9d505..ec1a22cf673fc0cae92268cf07b1fa597222c6d2 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -260,13 +260,10 @@ bool CopyDirectory(const FilePath& from_path,
// Some old callers of CopyDirectory want it to support wildcards.
// After some discussion, we decided to fix those callers.
// Break loudly here if anyone tries to do this.
- // TODO(evanm): remove this once we're sure it's ok.
DCHECK(to_path.value().find('*') == std::string::npos);
DCHECK(from_path.value().find('*') == std::string::npos);
- char top_dir[PATH_MAX];
- if (strlcpy(top_dir, from_path.value().c_str(),
- arraysize(top_dir)) >= arraysize(top_dir)) {
+ if (from_path.value().size() >= PATH_MAX) {
return false;
}
@@ -286,10 +283,10 @@ bool CopyDirectory(const FilePath& from_path,
return false;
if (real_to_path.value().size() >= real_from_path.value().size() &&
real_to_path.value().compare(0, real_from_path.value().size(),
- real_from_path.value()) == 0)
+ real_from_path.value()) == 0) {
return false;
+ }
- bool success = true;
int traverse_type = FileEnumerator::FILES | FileEnumerator::SHOW_SYM_LINKS;
if (recursive)
traverse_type |= FileEnumerator::DIRECTORIES;
@@ -302,7 +299,7 @@ bool CopyDirectory(const FilePath& from_path,
if (stat(from_path.value().c_str(), &from_stat) < 0) {
DLOG(ERROR) << "CopyDirectory() couldn't stat source directory: "
<< from_path.value() << " errno = " << errno;
- success = false;
+ return false;
}
struct stat to_path_stat;
FilePath from_path_base = from_path;
@@ -315,8 +312,10 @@ bool CopyDirectory(const FilePath& from_path,
// The Windows version of this function assumes that non-recursive calls
// will always have a directory for from_path.
+ // TODO(maruel): This is not necessary anymore.
DCHECK(recursive || S_ISDIR(from_stat.st_mode));
+ bool success = true;
while (success && !current.empty()) {
// current is the source path, including from_path, so append
// the suffix after from_path to to_path to create the target_path.
« no previous file with comments | « base/file_util.h ('k') | base/file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698