OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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 #ifndef THIRD_PARTY_ZLIB_GOOGLE_ZIP_H_ |
| 6 #define THIRD_PARTY_ZLIB_GOOGLE_ZIP_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "base/files/file_path.h" |
| 12 #include "build/build_config.h" |
| 13 |
| 14 namespace zip { |
| 15 |
| 16 // Zip the contents of src_dir into dest_file. src_path must be a directory. |
| 17 // An entry will *not* be created in the zip for the root folder -- children |
| 18 // of src_dir will be at the root level of the created zip. For each file in |
| 19 // src_dir, include it only if the callback |filter_cb| returns true. Otherwise |
| 20 // omit it. |
| 21 typedef base::Callback<bool(const base::FilePath&)> FilterCallback; |
| 22 bool ZipWithFilterCallback(const base::FilePath& src_dir, |
| 23 const base::FilePath& dest_file, |
| 24 const FilterCallback& filter_cb); |
| 25 |
| 26 // Convenience method for callers who don't need to set up the filter callback. |
| 27 // If |include_hidden_files| is true, files starting with "." are included. |
| 28 // Otherwise they are omitted. |
| 29 bool Zip(const base::FilePath& src_dir, const base::FilePath& dest_file, |
| 30 bool include_hidden_files); |
| 31 |
| 32 #if defined(OS_POSIX) |
| 33 // Zips files listed in |src_relative_paths| to destination specified by file |
| 34 // descriptor |dest_fd|, without taking ownership of |dest_fd|. The paths listed |
| 35 // in |src_relative_paths| are relative to the |src_dir| and will be used as the |
| 36 // file names in the created zip file. All source paths must be under |src_dir| |
| 37 // in the file system hierarchy. |
| 38 bool ZipFiles(const base::FilePath& src_dir, |
| 39 const std::vector<base::FilePath>& src_relative_paths, |
| 40 int dest_fd); |
| 41 #endif // defined(OS_POSIX) |
| 42 |
| 43 // Unzip the contents of zip_file into dest_dir. |
| 44 bool Unzip(const base::FilePath& zip_file, const base::FilePath& dest_dir); |
| 45 |
| 46 } // namespace zip |
| 47 |
| 48 #endif // THIRD_PARTY_ZLIB_GOOGLE_ZIP_H_ |
OLD | NEW |