| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/setup/archive_patch_helper.h" | 5 #include "chrome/installer/setup/archive_patch_helper.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 7 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 8 #include "base/logging.h" | 10 #include "base/logging.h" |
| 9 #include "chrome/installer/util/lzma_util.h" | 11 #include "chrome/installer/util/lzma_util.h" |
| 10 #include "courgette/courgette.h" | 12 #include "courgette/courgette.h" |
| 11 #include "third_party/bspatch/mbspatch.h" | 13 #include "third_party/bspatch/mbspatch.h" |
| 12 | 14 |
| 13 namespace installer { | 15 namespace installer { |
| 14 | 16 |
| 15 ArchivePatchHelper::ArchivePatchHelper(const base::FilePath& working_directory, | 17 ArchivePatchHelper::ArchivePatchHelper(const base::FilePath& working_directory, |
| 16 const base::FilePath& compressed_archive, | 18 const base::FilePath& compressed_archive, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 34 return (instance.Uncompress(NULL) && | 36 return (instance.Uncompress(NULL) && |
| 35 (instance.EnsemblePatch() || instance.BinaryPatch())); | 37 (instance.EnsemblePatch() || instance.BinaryPatch())); |
| 36 } | 38 } |
| 37 | 39 |
| 38 bool ArchivePatchHelper::Uncompress(base::FilePath* last_uncompressed_file) { | 40 bool ArchivePatchHelper::Uncompress(base::FilePath* last_uncompressed_file) { |
| 39 // The target shouldn't already exist. | 41 // The target shouldn't already exist. |
| 40 DCHECK(!base::PathExists(target_)); | 42 DCHECK(!base::PathExists(target_)); |
| 41 | 43 |
| 42 // UnPackArchive takes care of logging. | 44 // UnPackArchive takes care of logging. |
| 43 base::string16 output_file; | 45 base::string16 output_file; |
| 44 int32 lzma_result = LzmaUtil::UnPackArchive(compressed_archive_.value(), | 46 int32_t lzma_result = LzmaUtil::UnPackArchive( |
| 45 working_directory_.value(), | 47 compressed_archive_.value(), working_directory_.value(), &output_file); |
| 46 &output_file); | |
| 47 if (lzma_result != NO_ERROR) | 48 if (lzma_result != NO_ERROR) |
| 48 return false; | 49 return false; |
| 49 | 50 |
| 50 last_uncompressed_file_ = base::FilePath(output_file); | 51 last_uncompressed_file_ = base::FilePath(output_file); |
| 51 if (last_uncompressed_file) | 52 if (last_uncompressed_file) |
| 52 *last_uncompressed_file = last_uncompressed_file_; | 53 *last_uncompressed_file = last_uncompressed_file_; |
| 53 return true; | 54 return true; |
| 54 } | 55 } |
| 55 | 56 |
| 56 bool ArchivePatchHelper::EnsemblePatch() { | 57 bool ArchivePatchHelper::EnsemblePatch() { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 << " and generating file " << target_.value() | 97 << " and generating file " << target_.value() |
| 97 << " using bsdiff. err=" << result; | 98 << " using bsdiff. err=" << result; |
| 98 | 99 |
| 99 // Ensure a partial output is not left behind. | 100 // Ensure a partial output is not left behind. |
| 100 base::DeleteFile(target_, false); | 101 base::DeleteFile(target_, false); |
| 101 | 102 |
| 102 return false; | 103 return false; |
| 103 } | 104 } |
| 104 | 105 |
| 105 } // namespace installer | 106 } // namespace installer |
| OLD | NEW |