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 20 matching lines...) Expand all Loading... |
31 bool CopyTreeWorkItem::Do() { | 31 bool CopyTreeWorkItem::Do() { |
32 if (!base::PathExists(source_path_)) { | 32 if (!base::PathExists(source_path_)) { |
33 LOG(ERROR) << source_path_.value() << " does not exist"; | 33 LOG(ERROR) << source_path_.value() << " does not exist"; |
34 return false; | 34 return false; |
35 } | 35 } |
36 | 36 |
37 bool dest_exist = base::PathExists(dest_path_); | 37 bool dest_exist = base::PathExists(dest_path_); |
38 // handle overwrite_option_ = IF_DIFFERENT case. | 38 // handle overwrite_option_ = IF_DIFFERENT case. |
39 if ((dest_exist) && | 39 if ((dest_exist) && |
40 (overwrite_option_ == WorkItem::IF_DIFFERENT) && // only for single file | 40 (overwrite_option_ == WorkItem::IF_DIFFERENT) && // only for single file |
41 (!file_util::DirectoryExists(source_path_)) && | 41 (!base::DirectoryExists(source_path_)) && |
42 (!file_util::DirectoryExists(dest_path_)) && | 42 (!base::DirectoryExists(dest_path_)) && |
43 (file_util::ContentsEqual(source_path_, dest_path_))) { | 43 (base::ContentsEqual(source_path_, dest_path_))) { |
44 VLOG(1) << "Source file " << source_path_.value() | 44 VLOG(1) << "Source file " << source_path_.value() |
45 << " and destination file " << dest_path_.value() | 45 << " and destination file " << dest_path_.value() |
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 (!base::DirectoryExists(source_path_)) && |
51 (!file_util::DirectoryExists(dest_path_)) && | 51 (!base::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 base::PathExists(alternative_path_) || | 55 base::PathExists(alternative_path_) || |
56 !base::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; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |