OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_COMMON_ZIP_H_ | 5 #ifndef CHROME_COMMON_ZIP_H_ |
6 #define CHROME_COMMON_ZIP_H_ | 6 #define CHROME_COMMON_ZIP_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 | 9 #include "base/file_path.h" |
10 class FilePath; | |
11 | 10 |
12 namespace zip { | 11 namespace zip { |
13 | 12 |
14 // Zip the contents of src_dir into dest_file. src_path must be a directory. | 13 // Zip the contents of src_dir into dest_file. src_path must be a directory. |
15 // An entry will *not* be created in the zip for the root folder -- children | 14 // An entry will *not* be created in the zip for the root folder -- children |
16 // of src_dir will be at the root level of the created zip. For each file in | 15 // of src_dir will be at the root level of the created zip. For each file in |
17 // src_dir, include it only if the callback |filter_cb| returns true. Otherwise | 16 // src_dir, include it only if the callback |filter_cb| returns true. Otherwise |
18 // omit it. | 17 // omit it. |
19 typedef base::Callback<bool(const FilePath&)> FilterCallback; | 18 typedef base::Callback<bool(const FilePath&)> FilterCallback; |
20 bool ZipWithFilterCallback(const FilePath& src_dir, const FilePath& dest_file, | 19 bool ZipWithFilterCallback(const FilePath& src_dir, const FilePath& dest_file, |
21 const FilterCallback& filter_cb); | 20 const FilterCallback& filter_cb); |
22 | 21 |
23 // Convenience method for callers who don't need to set up the filter callback. | 22 // Convenience method for callers who don't need to set up the filter callback. |
24 // If |include_hidden_files| is true, files starting with "." are included. | 23 // If |include_hidden_files| is true, files starting with "." are included. |
25 // Otherwise they are omitted. | 24 // Otherwise they are omitted. |
26 bool Zip(const FilePath& src_dir, const FilePath& dest_file, | 25 bool Zip(const FilePath& src_dir, const FilePath& dest_file, |
27 bool include_hidden_files); | 26 bool include_hidden_files); |
28 | 27 |
| 28 // Zip the source files listed under src_file_list into dest_file. The src_dir |
| 29 // must be a directory. Source files in src_file_list must be children of |
| 30 // src_dir to be included in the created zip. Children of src_dir will be at the |
| 31 // root level of the created zip. |
| 32 bool ZipFileList(const FilePath& src_dir, const FilePath& dest_file, |
| 33 const std::vector<FilePath>& src_file_list); |
| 34 |
29 // Unzip the contents of zip_file into dest_dir. | 35 // Unzip the contents of zip_file into dest_dir. |
30 bool Unzip(const FilePath& zip_file, const FilePath& dest_dir); | 36 bool Unzip(const FilePath& zip_file, const FilePath& dest_dir); |
31 | 37 |
32 } // namespace zip | 38 } // namespace zip |
33 | 39 |
34 #endif // CHROME_COMMON_ZIP_H_ | 40 #endif // CHROME_COMMON_ZIP_H_ |
OLD | NEW |