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

Unified Diff: base/file_util_win.cc

Issue 11773018: Fix creating target paths in file_util_posix CopyDirectory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: support trailing separators in windows file_util::CopyDirectory Created 7 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 | « base/file_util_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util_win.cc
diff --git a/base/file_util_win.cc b/base/file_util_win.cc
index 2fd2399aa6391c2021edba9336ed89b7aa624d3c..f67b26c9a5d093f374f9b5f9489b1f07220f2390 100644
--- a/base/file_util_win.cc
+++ b/base/file_util_win.cc
@@ -204,12 +204,16 @@ bool CopyFile(const FilePath& from_path, const FilePath& to_path) {
bool ShellCopy(const FilePath& from_path, const FilePath& to_path,
bool recursive) {
+ // WinXP SHFileOperation doesn't like trailing separators.
+ FilePath stripped_from = from_path.StripTrailingSeparators();
+ FilePath stripped_to = to_path.StripTrailingSeparators();
+
base::ThreadRestrictions::AssertIOAllowed();
// NOTE: I suspect we could support longer paths, but that would involve
// analyzing all our usage of files.
- if (from_path.value().length() >= MAX_PATH ||
- to_path.value().length() >= MAX_PATH) {
+ if (stripped_from.value().length() >= MAX_PATH ||
+ stripped_to.value().length() >= MAX_PATH) {
return false;
}
@@ -219,9 +223,9 @@ bool ShellCopy(const FilePath& from_path, const FilePath& to_path,
wchar_t double_terminated_path_from[MAX_PATH + 1] = {0};
wchar_t double_terminated_path_to[MAX_PATH + 1] = {0};
#pragma warning(suppress:4996) // don't complain about wcscpy deprecation
- wcscpy(double_terminated_path_from, from_path.value().c_str());
+ wcscpy(double_terminated_path_from, stripped_from.value().c_str());
#pragma warning(suppress:4996) // don't complain about wcscpy deprecation
- wcscpy(double_terminated_path_to, to_path.value().c_str());
+ wcscpy(double_terminated_path_to, stripped_to.value().c_str());
SHFILEOPSTRUCT file_operation = {0};
file_operation.wFunc = FO_COPY;
« no previous file with comments | « base/file_util_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698