OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 5 |
6 #include "chrome/installer/util/duplicate_tree_detector.h" | 6 #include "chrome/installer/util/duplicate_tree_detector.h" |
7 | 7 |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 file_util::GetFileInfo(dest_path, &dest_info)) { | 21 file_util::GetFileInfo(dest_path, &dest_info)) { |
22 // Both paths exist, check the types: | 22 // Both paths exist, check the types: |
23 if (!src_info.is_directory && !dest_info.is_directory) { | 23 if (!src_info.is_directory && !dest_info.is_directory) { |
24 // Two files are "identical" if the file sizes are equivalent. | 24 // Two files are "identical" if the file sizes are equivalent. |
25 is_identical = src_info.size == dest_info.size; | 25 is_identical = src_info.size == dest_info.size; |
26 } else if (src_info.is_directory && dest_info.is_directory) { | 26 } else if (src_info.is_directory && dest_info.is_directory) { |
27 // Two directories are "identical" if dest_path contains entries that are | 27 // Two directories are "identical" if dest_path contains entries that are |
28 // "identical" to all the entries in src_path. | 28 // "identical" to all the entries in src_path. |
29 is_identical = true; | 29 is_identical = true; |
30 | 30 |
31 FileEnumerator path_enum( | 31 FileEnumerator path_enum(src_path, false /* not recursive */, |
32 src_path, | 32 FileEnumerator::FILES | FileEnumerator::DIRECTORIES); |
33 false, // Not recursive | |
34 static_cast<FileEnumerator::FileType>( | |
35 FileEnumerator::FILES | FileEnumerator::DIRECTORIES)); | |
36 for (FilePath path = path_enum.Next(); is_identical && !path.empty(); | 33 for (FilePath path = path_enum.Next(); is_identical && !path.empty(); |
37 path = path_enum.Next()) { | 34 path = path_enum.Next()) { |
38 is_identical = | 35 is_identical = |
39 IsIdenticalFileHierarchy(path, dest_path.Append(path.BaseName())); | 36 IsIdenticalFileHierarchy(path, dest_path.Append(path.BaseName())); |
40 } | 37 } |
41 } else { | 38 } else { |
42 // The two paths are of different types, so they cannot be identical. | 39 // The two paths are of different types, so they cannot be identical. |
43 DCHECK(!is_identical); | 40 DCHECK(!is_identical); |
44 } | 41 } |
45 } | 42 } |
46 | 43 |
47 return is_identical; | 44 return is_identical; |
48 } | 45 } |
49 | 46 |
50 } // namespace installer | 47 } // namespace installer |
OLD | NEW |