| 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 // This file declares util functions for setup project. | 5 // This file declares util functions for setup project. |
| 6 | 6 |
| 7 #include "chrome/installer/setup/setup_util.h" | 7 #include "chrome/installer/setup/setup_util.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" |
| 11 #include "chrome/installer/util/master_preferences.h" | 11 #include "chrome/installer/util/master_preferences.h" |
| 12 #include "chrome/installer/util/util_constants.h" | 12 #include "chrome/installer/util/util_constants.h" |
| 13 #include "courgette/courgette.h" | 13 #include "courgette/courgette.h" |
| 14 #include "third_party/bspatch/mbspatch.h" | 14 #include "third_party/bspatch/mbspatch.h" |
| 15 | 15 |
| 16 int installer::ApplyDiffPatch(const FilePath& src, | 16 int setup_util::ApplyDiffPatch(const FilePath& src, |
| 17 const FilePath& patch, | 17 const FilePath& patch, |
| 18 const FilePath& dest) { | 18 const FilePath& dest) { |
| 19 VLOG(1) << "Applying patch " << patch.value() << " to file " << src.value() | 19 VLOG(1) << "Applying patch " << patch.value() << " to file " << src.value() |
| 20 << " and generating file " << dest.value(); | 20 << " and generating file " << dest.value(); |
| 21 | 21 |
| 22 // Try Courgette first. Courgette checks the patch file first and fails | 22 // Try Courgette first. Courgette checks the patch file first and fails |
| 23 // quickly if the patch file does not have a valid Courgette header. | 23 // quickly if the patch file does not have a valid Courgette header. |
| 24 courgette::Status patch_status = | 24 courgette::Status patch_status = |
| 25 courgette::ApplyEnsemblePatch(src.value().c_str(), | 25 courgette::ApplyEnsemblePatch(src.value().c_str(), |
| 26 patch.value().c_str(), | 26 patch.value().c_str(), |
| 27 dest.value().c_str()); | 27 dest.value().c_str()); |
| 28 if (patch_status == courgette::C_OK) | 28 if (patch_status == courgette::C_OK) |
| 29 return 0; | 29 return 0; |
| 30 | 30 |
| 31 VLOG(1) << "Failed to apply patch " << patch.value() << " using courgette."; | 31 VLOG(1) << "Failed to apply patch " << patch.value() << " using courgette."; |
| 32 return ApplyBinaryPatch(src.value().c_str(), patch.value().c_str(), | 32 return ApplyBinaryPatch(src.value().c_str(), patch.value().c_str(), |
| 33 dest.value().c_str()); | 33 dest.value().c_str()); |
| 34 } | 34 } |
| 35 | 35 |
| 36 installer::Version* installer::GetVersionFromArchiveDir( | 36 installer::Version* setup_util::GetVersionFromArchiveDir( |
| 37 const FilePath& chrome_path) { | 37 const FilePath& chrome_path) { |
| 38 VLOG(1) << "Looking for Chrome version folder under " << chrome_path.value(); | 38 VLOG(1) << "Looking for Chrome version folder under " << chrome_path.value(); |
| 39 FilePath root_path = chrome_path.Append(L"*"); | 39 FilePath root_path = chrome_path.Append(L"*"); |
| 40 | 40 |
| 41 // TODO(tommi): The version directory really should match the version of | 41 // TODO(tommi): The version directory really should match the version of |
| 42 // setup.exe. To begin with, we should at least DCHECK that that's true. | 42 // setup.exe. To begin with, we should at least DCHECK that that's true. |
| 43 | 43 |
| 44 // TODO(tommi): use file_util::FileEnumerator. | 44 // TODO(tommi): use file_util::FileEnumerator. |
| 45 WIN32_FIND_DATA find_data = {0}; | 45 WIN32_FIND_DATA find_data = {0}; |
| 46 HANDLE file_handle = FindFirstFile(root_path.value().c_str(), &find_data); | 46 HANDLE file_handle = FindFirstFile(root_path.value().c_str(), &find_data); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 57 version = installer::Version::GetVersionFromString(find_data.cFileName); | 57 version = installer::Version::GetVersionFromString(find_data.cFileName); |
| 58 if (version) | 58 if (version) |
| 59 break; | 59 break; |
| 60 } | 60 } |
| 61 ret = FindNextFile(file_handle, &find_data); | 61 ret = FindNextFile(file_handle, &find_data); |
| 62 } | 62 } |
| 63 FindClose(file_handle); | 63 FindClose(file_handle); |
| 64 | 64 |
| 65 return version; | 65 return version; |
| 66 } | 66 } |
| OLD | NEW |