Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <dirent.h> | 7 #include <dirent.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <fcntl.h> | 9 #include <fcntl.h> |
| 10 #include <libgen.h> | 10 #include <libgen.h> |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 if (real_to_path.empty()) | 269 if (real_to_path.empty()) |
| 270 return false; | 270 return false; |
| 271 } else { | 271 } else { |
| 272 real_to_path = MakeAbsoluteFilePath(real_to_path.DirName()); | 272 real_to_path = MakeAbsoluteFilePath(real_to_path.DirName()); |
| 273 if (real_to_path.empty()) | 273 if (real_to_path.empty()) |
| 274 return false; | 274 return false; |
| 275 } | 275 } |
| 276 FilePath real_from_path = MakeAbsoluteFilePath(from_path); | 276 FilePath real_from_path = MakeAbsoluteFilePath(from_path); |
| 277 if (real_from_path.empty()) | 277 if (real_from_path.empty()) |
| 278 return false; | 278 return false; |
| 279 if (real_to_path.value().size() >= real_from_path.value().size() && | 279 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: omit braces for consistency with the conditio
| |
| 280 real_to_path.value().compare(0, real_from_path.value().size(), | |
| 281 real_from_path.value()) == 0) { | |
| 282 return false; | 280 return false; |
| 283 } | 281 } |
| 284 | 282 |
| 285 int traverse_type = FileEnumerator::FILES | FileEnumerator::SHOW_SYM_LINKS; | 283 int traverse_type = FileEnumerator::FILES | FileEnumerator::SHOW_SYM_LINKS; |
| 286 if (recursive) | 284 if (recursive) |
| 287 traverse_type |= FileEnumerator::DIRECTORIES; | 285 traverse_type |= FileEnumerator::DIRECTORIES; |
| 288 FileEnumerator traversal(from_path, recursive, traverse_type); | 286 FileEnumerator traversal(from_path, recursive, traverse_type); |
| 289 | 287 |
| 290 // We have to mimic windows behavior here. |to_path| may not exist yet, | 288 // We have to mimic windows behavior here. |to_path| may not exist yet, |
| 291 // start the loop with |to_path|. | 289 // start the loop with |to_path|. |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 985 return false; | 983 return false; |
| 986 | 984 |
| 987 DeleteFile(from_path, true); | 985 DeleteFile(from_path, true); |
| 988 return true; | 986 return true; |
| 989 } | 987 } |
| 990 | 988 |
| 991 } // namespace internal | 989 } // namespace internal |
| 992 | 990 |
| 993 #endif // !defined(OS_NACL_NONSFI) | 991 #endif // !defined(OS_NACL_NONSFI) |
| 994 } // namespace base | 992 } // namespace base |
| OLD | NEW |