OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/installer/util/copy_tree_work_item.h" | 5 #include "chrome/installer/util/copy_tree_work_item.h" |
6 | 6 |
7 #include <shlwapi.h> | 7 #include <shlwapi.h> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 << " are exactly same. Returning true."; | 46 << " are exactly same. Returning true."; |
47 return true; | 47 return true; |
48 } else if ((dest_exist) && | 48 } else if ((dest_exist) && |
49 (overwrite_option_ == WorkItem::NEW_NAME_IF_IN_USE) && | 49 (overwrite_option_ == WorkItem::NEW_NAME_IF_IN_USE) && |
50 (!file_util::DirectoryExists(source_path_)) && | 50 (!file_util::DirectoryExists(source_path_)) && |
51 (!file_util::DirectoryExists(dest_path_)) && | 51 (!file_util::DirectoryExists(dest_path_)) && |
52 (IsFileInUse(dest_path_))) { | 52 (IsFileInUse(dest_path_))) { |
53 // handle overwrite_option_ = NEW_NAME_IF_IN_USE case. | 53 // handle overwrite_option_ = NEW_NAME_IF_IN_USE case. |
54 if (alternative_path_.empty() || | 54 if (alternative_path_.empty() || |
55 file_util::PathExists(alternative_path_) || | 55 file_util::PathExists(alternative_path_) || |
56 !file_util::CopyFile(source_path_, alternative_path_)) { | 56 !base::CopyFile(source_path_, alternative_path_)) { |
57 LOG(ERROR) << "failed to copy " << source_path_.value() | 57 LOG(ERROR) << "failed to copy " << source_path_.value() |
58 << " to " << alternative_path_.value(); | 58 << " to " << alternative_path_.value(); |
59 return false; | 59 return false; |
60 } else { | 60 } else { |
61 copied_to_alternate_path_ = true; | 61 copied_to_alternate_path_ = true; |
62 VLOG(1) << "Copied source file " << source_path_.value() | 62 VLOG(1) << "Copied source file " << source_path_.value() |
63 << " to alternative path " << alternative_path_.value(); | 63 << " to alternative path " << alternative_path_.value(); |
64 return true; | 64 return true; |
65 } | 65 } |
66 } else if ((dest_exist) && | 66 } else if ((dest_exist) && |
(...skipping 16 matching lines...) Expand all Loading... |
83 VLOG(1) << "Moved destination " << dest_path_.value() << | 83 VLOG(1) << "Moved destination " << dest_path_.value() << |
84 " to backup path " << backup.value(); | 84 " to backup path " << backup.value(); |
85 } else { | 85 } else { |
86 LOG(ERROR) << "failed moving " << dest_path_.value() | 86 LOG(ERROR) << "failed moving " << dest_path_.value() |
87 << " to " << backup.value(); | 87 << " to " << backup.value(); |
88 return false; | 88 return false; |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 // In all cases that reach here, copy source to destination. | 92 // In all cases that reach here, copy source to destination. |
93 if (file_util::CopyDirectory(source_path_, dest_path_, true)) { | 93 if (base::CopyDirectory(source_path_, dest_path_, true)) { |
94 copied_to_dest_path_ = true; | 94 copied_to_dest_path_ = true; |
95 VLOG(1) << "Copied source " << source_path_.value() | 95 VLOG(1) << "Copied source " << source_path_.value() |
96 << " to destination " << dest_path_.value(); | 96 << " to destination " << dest_path_.value(); |
97 } else { | 97 } else { |
98 LOG(ERROR) << "failed copy " << source_path_.value() | 98 LOG(ERROR) << "failed copy " << source_path_.value() |
99 << " to " << dest_path_.value(); | 99 << " to " << dest_path_.value(); |
100 return false; | 100 return false; |
101 } | 101 } |
102 | 102 |
103 return true; | 103 return true; |
(...skipping 26 matching lines...) Expand all Loading... |
130 return false; | 130 return false; |
131 | 131 |
132 HANDLE handle = ::CreateFile(path.value().c_str(), FILE_ALL_ACCESS, | 132 HANDLE handle = ::CreateFile(path.value().c_str(), FILE_ALL_ACCESS, |
133 NULL, NULL, OPEN_EXISTING, NULL, NULL); | 133 NULL, NULL, OPEN_EXISTING, NULL, NULL); |
134 if (handle == INVALID_HANDLE_VALUE) | 134 if (handle == INVALID_HANDLE_VALUE) |
135 return true; | 135 return true; |
136 | 136 |
137 CloseHandle(handle); | 137 CloseHandle(handle); |
138 return false; | 138 return false; |
139 } | 139 } |
OLD | NEW |