Index: mojo/tools/package_manager/unpacker.cc |
diff --git a/mojo/tools/package_manager/unpacker.cc b/mojo/tools/package_manager/unpacker.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..39f26743bac72972e11da14dfcee3f4c0fcf0694 |
--- /dev/null |
+++ b/mojo/tools/package_manager/unpacker.cc |
@@ -0,0 +1,37 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "mojo/tools/package_manager/unpacker.h" |
+ |
+#include "base/files/file_util.h" |
+#include "base/logging.h" |
+#include "third_party/zlib/google/zip.h" |
+ |
+namespace mojo { |
+ |
+Unpacker::Unpacker() { |
+} |
+ |
+Unpacker::~Unpacker() { |
+ if (!dir_.empty()) { |
+ printf("Deleting %s\n", dir_.value().c_str()); |
+ //DeleteFile(dir_, true); |
+ } |
+} |
+ |
+bool Unpacker::Unpack(const base::FilePath& zip_file) { |
+ DCHECK(zip_file_.empty()); |
+ zip_file_ = zip_file; |
+ |
+ DCHECK(dir_.empty()); |
+ if (!CreateNewTempDirectory(base::FilePath::StringType(), &dir_)) |
+ return false; |
+ if (!zip::Unzip(zip_file, dir_)) { |
+ dir_ = base::FilePath(); |
+ return false; |
+ } |
+ return true; |
+} |
+ |
+} // namespace mojo |