| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/lzma_util.h" | 5 #include "chrome/installer/util/lzma_util.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 |
| 7 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 9 #include "base/logging.h" | 11 #include "base/logging.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/installer/util/lzma_file_allocator.h" | 13 #include "chrome/installer/util/lzma_file_allocator.h" |
| 12 | 14 |
| 13 extern "C" { | 15 extern "C" { |
| 14 #include "third_party/lzma_sdk/7z.h" | 16 #include "third_party/lzma_sdk/7z.h" |
| 15 #include "third_party/lzma_sdk/7zAlloc.h" | 17 #include "third_party/lzma_sdk/7zAlloc.h" |
| 16 #include "third_party/lzma_sdk/7zCrc.h" | 18 #include "third_party/lzma_sdk/7zCrc.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 73 } |
| 72 | 74 |
| 73 SRes SzFileReadImp(void *object, void *buffer, size_t *size) { | 75 SRes SzFileReadImp(void *object, void *buffer, size_t *size) { |
| 74 CFileInStream *s = (CFileInStream *) object; | 76 CFileInStream *s = (CFileInStream *) object; |
| 75 return LzmaReadFile(s->file.handle, buffer, size); | 77 return LzmaReadFile(s->file.handle, buffer, size); |
| 76 } | 78 } |
| 77 | 79 |
| 78 } // namespace | 80 } // namespace |
| 79 | 81 |
| 80 // static | 82 // static |
| 81 int32 LzmaUtil::UnPackArchive(const std::wstring& archive, | 83 int32_t LzmaUtil::UnPackArchive(const std::wstring& archive, |
| 82 const std::wstring& output_dir, | 84 const std::wstring& output_dir, |
| 83 std::wstring* output_file) { | 85 std::wstring* output_file) { |
| 84 VLOG(1) << "Opening archive " << archive; | 86 VLOG(1) << "Opening archive " << archive; |
| 85 LzmaUtil lzma_util; | 87 LzmaUtil lzma_util; |
| 86 DWORD ret; | 88 DWORD ret; |
| 87 if ((ret = lzma_util.OpenArchive(archive)) != NO_ERROR) { | 89 if ((ret = lzma_util.OpenArchive(archive)) != NO_ERROR) { |
| 88 LOG(ERROR) << "Unable to open install archive: " << archive | 90 LOG(ERROR) << "Unable to open install archive: " << archive |
| 89 << ", error: " << ret; | 91 << ", error: " << ret; |
| 90 } else { | 92 } else { |
| 91 VLOG(1) << "Uncompressing archive to path " << output_dir; | 93 VLOG(1) << "Uncompressing archive to path " << output_dir; |
| 92 if ((ret = lzma_util.UnPack(output_dir, output_file)) != NO_ERROR) { | 94 if ((ret = lzma_util.UnPack(output_dir, output_file)) != NO_ERROR) { |
| 93 LOG(ERROR) << "Unable to uncompress archive: " << archive | 95 LOG(ERROR) << "Unable to uncompress archive: " << archive |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 | 248 |
| 247 bool LzmaUtil::CreateDirectory(const base::FilePath& dir) { | 249 bool LzmaUtil::CreateDirectory(const base::FilePath& dir) { |
| 248 bool ret = true; | 250 bool ret = true; |
| 249 if (directories_created_.find(dir.value()) == directories_created_.end()) { | 251 if (directories_created_.find(dir.value()) == directories_created_.end()) { |
| 250 ret = base::CreateDirectory(dir); | 252 ret = base::CreateDirectory(dir); |
| 251 if (ret) | 253 if (ret) |
| 252 directories_created_.insert(dir.value()); | 254 directories_created_.insert(dir.value()); |
| 253 } | 255 } |
| 254 return ret; | 256 return ret; |
| 255 } | 257 } |
| OLD | NEW |