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

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

Issue 2577163002: A follow-up nit fix for jumplist file operations (Closed)
Patch Set: 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
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 180 if (real_to_path == real_from_path || real_from_path.IsParent(real_to_path)) {
grt (UTC plus 2) 2016/12/15 21:28:32 nit: no braces
181 // result in a false negative, e.g. on C:\bar\Foo versus C:\bar\FooOld.
chengx 2016/12/15 19:51:54 grt@ nit: i think this comment is unnecessary. th
182 if (real_to_path.value().size() >= real_from_path.value().size() &&
183 real_from_path.IsParent(real_to_path)) {
chengx 2016/12/15 19:51:54 grt@ this "optimization" seems wrong to me -- eit
184 return false; 181 return false;
185 } 182 }
186 183
187 int traverse_type = FileEnumerator::FILES; 184 int traverse_type = FileEnumerator::FILES;
188 if (recursive) 185 if (recursive)
189 traverse_type |= FileEnumerator::DIRECTORIES; 186 traverse_type |= FileEnumerator::DIRECTORIES;
190 FileEnumerator traversal(from_path, recursive, traverse_type); 187 FileEnumerator traversal(from_path, recursive, traverse_type);
191 188
192 if (!PathExists(from_path)) { 189 if (!PathExists(from_path)) {
193 DLOG(ERROR) << "CopyDirectory() couldn't stat source directory: " 190 DLOG(ERROR) << "CopyDirectory() couldn't stat source directory: "
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 // Like Move, this function is not transactional, so we just 821 // Like Move, this function is not transactional, so we just
825 // leave the copied bits behind if deleting from_path fails. 822 // leave the copied bits behind if deleting from_path fails.
826 // If to_path exists previously then we have already overwritten 823 // If to_path exists previously then we have already overwritten
827 // it by now, we don't get better off by deleting the new bits. 824 // it by now, we don't get better off by deleting the new bits.
828 } 825 }
829 return false; 826 return false;
830 } 827 }
831 828
832 } // namespace internal 829 } // namespace internal
833 } // namespace base 830 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698