| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "mojo/tools/package_manager/unpacker.h" | 5 #include "mojo/tools/package_manager/unpacker.h" |
| 6 | 6 |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "third_party/zlib/google/zip.h" | 9 #include "third_party/zlib/google/zip.h" |
| 10 | 10 |
| 11 namespace mojo { | 11 namespace mojo { |
| 12 | 12 |
| 13 Unpacker::Unpacker() { | 13 Unpacker::Unpacker() { |
| 14 } | 14 } |
| 15 | 15 |
| 16 Unpacker::~Unpacker() { | 16 Unpacker::~Unpacker() { |
| 17 if (!dir_.empty()) { | 17 if (!dir_.empty()) |
| 18 printf("Deleting %s\n", dir_.value().c_str()); | 18 DeleteFile(dir_, true); |
| 19 //DeleteFile(dir_, true); | |
| 20 } | |
| 21 } | 19 } |
| 22 | 20 |
| 23 bool Unpacker::Unpack(const base::FilePath& zip_file) { | 21 bool Unpacker::Unpack(const base::FilePath& zip_file) { |
| 24 DCHECK(zip_file_.empty()); | 22 DCHECK(zip_file_.empty()); |
| 25 zip_file_ = zip_file; | 23 zip_file_ = zip_file; |
| 26 | 24 |
| 27 DCHECK(dir_.empty()); | 25 DCHECK(dir_.empty()); |
| 28 if (!CreateNewTempDirectory(base::FilePath::StringType(), &dir_)) | 26 if (!CreateNewTempDirectory(base::FilePath::StringType(), &dir_)) |
| 29 return false; | 27 return false; |
| 30 if (!zip::Unzip(zip_file, dir_)) { | 28 if (!zip::Unzip(zip_file, dir_)) { |
| 31 dir_ = base::FilePath(); | 29 dir_ = base::FilePath(); |
| 32 return false; | 30 return false; |
| 33 } | 31 } |
| 34 return true; | 32 return true; |
| 35 } | 33 } |
| 36 | 34 |
| 37 } // namespace mojo | 35 } // namespace mojo |
| OLD | NEW |