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

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: whitespace Created 6 years, 11 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 | « no previous file | base/file_util_unittest.cc » ('j') | base/file_util_win.cc » ('J')
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..0ce61f92c6b338269c58305c6132b7a1b3e6ef08 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(),
M-A Ruel 2014/01/24 19:52:31 There was no point in doing a strlcpy just to get
- arraysize(top_dir)) >= arraysize(top_dir)) {
+ if (strlen(from_path.value().c_str()) >= PATH_MAX) {
grt (UTC plus 2) 2014/01/24 20:50:07 no need for strlen, either, is there? if (from_p
M-A Ruel 2014/01/24 21:32:57 Done.
return false;
}
@@ -289,7 +286,6 @@ bool CopyDirectory(const FilePath& from_path,
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 +298,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 +311,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 | « no previous file | base/file_util_unittest.cc » ('j') | base/file_util_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698