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

Side by Side Diff: base/files/file_util_win.cc

Issue 2570693002: Fix base::CopyDirectory() and JumpListIcons(Old) folders' operation logic (Closed)
Patch Set: Update some comments Created 4 years 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
« no previous file with comments | « no previous file | chrome/browser/win/jumplist.cc » ('j') | chrome/browser/win/jumplist.cc » ('J')
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/files/file_util.h" 5 #include "base/files/file_util.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <io.h> 8 #include <io.h>
9 #include <psapi.h> 9 #include <psapi.h>
10 #include <shellapi.h> 10 #include <shellapi.h>
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 if (real_to_path.empty()) 170 if (real_to_path.empty())
171 return false; 171 return false;
172 } else { 172 } else {
173 real_to_path = MakeAbsoluteFilePath(real_to_path.DirName()); 173 real_to_path = MakeAbsoluteFilePath(real_to_path.DirName());
174 if (real_to_path.empty()) 174 if (real_to_path.empty())
175 return false; 175 return false;
176 } 176 }
177 FilePath real_from_path = MakeAbsoluteFilePath(from_path); 177 FilePath real_from_path = MakeAbsoluteFilePath(from_path);
178 if (real_from_path.empty()) 178 if (real_from_path.empty())
179 return false; 179 return false;
180 // Note: it's important to use IsParent() here as string comparison would
grt (UTC plus 2) 2016/12/15 09:23:55 nit: i think this comment is unnecessary. the File
181 // result in a false negative, e.g. on C:\bar\Foo versus C:\bar\FooOld.
180 if (real_to_path.value().size() >= real_from_path.value().size() && 182 if (real_to_path.value().size() >= real_from_path.value().size() &&
grt (UTC plus 2) 2016/12/15 09:23:55 this "optimization" seems wrong to me -- either a
181 real_to_path.value().compare(0, real_from_path.value().size(), 183 real_from_path.IsParent(real_to_path)) {
grt (UTC plus 2) 2016/12/15 09:23:55 please make this same fix in file_util_posix
182 real_from_path.value()) == 0) {
183 return false; 184 return false;
184 } 185 }
185 186
186 int traverse_type = FileEnumerator::FILES; 187 int traverse_type = FileEnumerator::FILES;
187 if (recursive) 188 if (recursive)
188 traverse_type |= FileEnumerator::DIRECTORIES; 189 traverse_type |= FileEnumerator::DIRECTORIES;
189 FileEnumerator traversal(from_path, recursive, traverse_type); 190 FileEnumerator traversal(from_path, recursive, traverse_type);
190 191
191 if (!PathExists(from_path)) { 192 if (!PathExists(from_path)) {
192 DLOG(ERROR) << "CopyDirectory() couldn't stat source directory: " 193 DLOG(ERROR) << "CopyDirectory() couldn't stat source directory: "
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 // Like Move, this function is not transactional, so we just 824 // Like Move, this function is not transactional, so we just
824 // leave the copied bits behind if deleting from_path fails. 825 // leave the copied bits behind if deleting from_path fails.
825 // If to_path exists previously then we have already overwritten 826 // If to_path exists previously then we have already overwritten
826 // it by now, we don't get better off by deleting the new bits. 827 // it by now, we don't get better off by deleting the new bits.
827 } 828 }
828 return false; 829 return false;
829 } 830 }
830 831
831 } // namespace internal 832 } // namespace internal
832 } // namespace base 833 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/win/jumplist.cc » ('j') | chrome/browser/win/jumplist.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698