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)) |
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 } | |
284 | 281 |
285 int traverse_type = FileEnumerator::FILES | FileEnumerator::SHOW_SYM_LINKS; | 282 int traverse_type = FileEnumerator::FILES | FileEnumerator::SHOW_SYM_LINKS; |
286 if (recursive) | 283 if (recursive) |
287 traverse_type |= FileEnumerator::DIRECTORIES; | 284 traverse_type |= FileEnumerator::DIRECTORIES; |
288 FileEnumerator traversal(from_path, recursive, traverse_type); | 285 FileEnumerator traversal(from_path, recursive, traverse_type); |
289 | 286 |
290 // We have to mimic windows behavior here. |to_path| may not exist yet, | 287 // We have to mimic windows behavior here. |to_path| may not exist yet, |
291 // start the loop with |to_path|. | 288 // start the loop with |to_path|. |
292 struct stat from_stat; | 289 struct stat from_stat; |
293 FilePath current = from_path; | 290 FilePath current = from_path; |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 return false; | 982 return false; |
986 | 983 |
987 DeleteFile(from_path, true); | 984 DeleteFile(from_path, true); |
988 return true; | 985 return true; |
989 } | 986 } |
990 | 987 |
991 } // namespace internal | 988 } // namespace internal |
992 | 989 |
993 #endif // !defined(OS_NACL_NONSFI) | 990 #endif // !defined(OS_NACL_NONSFI) |
994 } // namespace base | 991 } // namespace base |
OLD | NEW |