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

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

Issue 2570693002: Fix base::CopyDirectory() and JumpListIcons(Old) folders' operation logic (Closed)
Patch Set: Fix deletion logic for JumpListIcon folder 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 // Originally this CopyDirectory() returns false when |to_path| string
181 // contains |from_path| string. While this can be that the to_path is within
182 // the from_path, e.g., parent-child relationship if they are both folders, it
183 // also can be that the two paths are in the same folder, just that one name
184 // contains the other, e.g. C:\\JumpListIcon and C:\\JumpListIconOld.
gab 2016/12/13 21:31:21 s/JumpListIcon/Foo/ in example (since this is in /
chengx 2016/12/13 23:00:39 Done.
185 // We make this function not return false in the latter situation by calling
186 // IsParent() function as below. This allows the copy-n-delete code after the
187 // "return false" below to execute.
gab 2016/12/13 21:31:21 No need to describe history here IMO, just say: /
chengx 2016/12/13 23:00:39 Done.
180 if (real_to_path.value().size() >= real_from_path.value().size() && 188 if (real_to_path.value().size() >= real_from_path.value().size() &&
181 real_to_path.value().compare(0, real_from_path.value().size(), 189 real_from_path.IsParent(real_to_path)) {
182 real_from_path.value()) == 0) {
183 return false; 190 return false;
184 } 191 }
185 192
186 int traverse_type = FileEnumerator::FILES; 193 int traverse_type = FileEnumerator::FILES;
187 if (recursive) 194 if (recursive)
188 traverse_type |= FileEnumerator::DIRECTORIES; 195 traverse_type |= FileEnumerator::DIRECTORIES;
189 FileEnumerator traversal(from_path, recursive, traverse_type); 196 FileEnumerator traversal(from_path, recursive, traverse_type);
190 197
191 if (!PathExists(from_path)) { 198 if (!PathExists(from_path)) {
192 DLOG(ERROR) << "CopyDirectory() couldn't stat source directory: " 199 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 830 // Like Move, this function is not transactional, so we just
824 // leave the copied bits behind if deleting from_path fails. 831 // leave the copied bits behind if deleting from_path fails.
825 // If to_path exists previously then we have already overwritten 832 // 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. 833 // it by now, we don't get better off by deleting the new bits.
827 } 834 }
828 return false; 835 return false;
829 } 836 }
830 837
831 } // namespace internal 838 } // namespace internal
832 } // namespace base 839 } // 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