OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "mojo/tools/package_manager/unpacker.h" |
| 6 |
| 7 #include "base/files/file_util.h" |
| 8 #include "base/logging.h" |
| 9 #include "third_party/zlib/google/zip.h" |
| 10 |
| 11 namespace mojo { |
| 12 |
| 13 Unpacker::Unpacker() { |
| 14 } |
| 15 |
| 16 Unpacker::~Unpacker() { |
| 17 if (!dir_.empty()) { |
| 18 printf("Deleting %s\n", dir_.value().c_str()); |
| 19 //DeleteFile(dir_, true); |
| 20 } |
| 21 } |
| 22 |
| 23 bool Unpacker::Unpack(const base::FilePath& zip_file) { |
| 24 DCHECK(zip_file_.empty()); |
| 25 zip_file_ = zip_file; |
| 26 |
| 27 DCHECK(dir_.empty()); |
| 28 if (!CreateNewTempDirectory(base::FilePath::StringType(), &dir_)) |
| 29 return false; |
| 30 if (!zip::Unzip(zip_file, dir_)) { |
| 31 dir_ = base::FilePath(); |
| 32 return false; |
| 33 } |
| 34 return true; |
| 35 } |
| 36 |
| 37 } // namespace mojo |
OLD | NEW |