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/test/test_file_util.h" | 5 #include "base/test/test_file_util.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 const base::FilePath& dest_dir) { | 83 const base::FilePath& dest_dir) { |
84 char top_dir[PATH_MAX]; | 84 char top_dir[PATH_MAX]; |
85 if (base::strlcpy(top_dir, source_dir.value().c_str(), | 85 if (base::strlcpy(top_dir, source_dir.value().c_str(), |
86 arraysize(top_dir)) >= arraysize(top_dir)) { | 86 arraysize(top_dir)) >= arraysize(top_dir)) { |
87 return false; | 87 return false; |
88 } | 88 } |
89 | 89 |
90 // This function does not properly handle destinations within the source | 90 // This function does not properly handle destinations within the source |
91 base::FilePath real_to_path = dest_dir; | 91 base::FilePath real_to_path = dest_dir; |
92 if (PathExists(real_to_path)) { | 92 if (PathExists(real_to_path)) { |
93 if (!AbsolutePath(&real_to_path)) | 93 real_to_path = MakeAbsoluteFilePath(real_to_path); |
| 94 if (real_to_path.empty()) |
94 return false; | 95 return false; |
95 } else { | 96 } else { |
96 real_to_path = real_to_path.DirName(); | 97 real_to_path = MakeAbsoluteFilePath(real_to_path.DirName()); |
97 if (!AbsolutePath(&real_to_path)) | 98 if (real_to_path.empty()) |
98 return false; | 99 return false; |
99 } | 100 } |
100 if (real_to_path.value().compare(0, source_dir.value().size(), | 101 if (real_to_path.value().compare(0, source_dir.value().size(), |
101 source_dir.value()) == 0) | 102 source_dir.value()) == 0) |
102 return false; | 103 return false; |
103 | 104 |
104 bool success = true; | 105 bool success = true; |
105 int traverse_type = FileEnumerator::FILES | | 106 int traverse_type = FileEnumerator::FILES | |
106 FileEnumerator::SHOW_SYM_LINKS | FileEnumerator::DIRECTORIES; | 107 FileEnumerator::SHOW_SYM_LINKS | FileEnumerator::DIRECTORIES; |
107 FileEnumerator traversal(source_dir, true, traverse_type); | 108 FileEnumerator traversal(source_dir, true, traverse_type); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 DCHECK(info_ != NULL); | 184 DCHECK(info_ != NULL); |
184 DCHECK_NE(0u, length_); | 185 DCHECK_NE(0u, length_); |
185 } | 186 } |
186 | 187 |
187 PermissionRestorer::~PermissionRestorer() { | 188 PermissionRestorer::~PermissionRestorer() { |
188 if (!RestorePermissionInfo(path_, info_, length_)) | 189 if (!RestorePermissionInfo(path_, info_, length_)) |
189 NOTREACHED(); | 190 NOTREACHED(); |
190 } | 191 } |
191 | 192 |
192 } // namespace file_util | 193 } // namespace file_util |
OLD | NEW |