Extract SIGPIPE ignoring code to a common place.
[chromium-blink-merge.git] / chrome / common / zip.h
blobfeda10109e7fb42703552a7a35186ea504f7adc6
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.
5 #ifndef CHROME_COMMON_ZIP_H_
6 #define CHROME_COMMON_ZIP_H_
8 #include "base/callback.h"
9 #include "base/file_path.h"
11 namespace zip {
13 // Zip the contents of src_dir into dest_file. src_path must be a directory.
14 // An entry will *not* be created in the zip for the root folder -- children
15 // of src_dir will be at the root level of the created zip. For each file in
16 // src_dir, include it only if the callback |filter_cb| returns true. Otherwise
17 // omit it.
18 typedef base::Callback<bool(const FilePath&)> FilterCallback;
19 bool ZipWithFilterCallback(const FilePath& src_dir, const FilePath& dest_file,
20 const FilterCallback& filter_cb);
22 // Convenience method for callers who don't need to set up the filter callback.
23 // If |include_hidden_files| is true, files starting with "." are included.
24 // Otherwise they are omitted.
25 bool Zip(const FilePath& src_dir, const FilePath& dest_file,
26 bool include_hidden_files);
28 // Zips files listed in |src_relative_paths| to |dest_file|.
29 // The paths listed in |src_relative_paths| are relative to |src_dir| and will
30 // be used as the file names in the created zip file. All source paths must be
31 // under |src_dir| in the file system hierarchy.
32 bool ZipFiles(const FilePath& src_dir,
33 const std::vector<FilePath>& src_relative_paths,
34 const FilePath& dest_file);
36 // Unzip the contents of zip_file into dest_dir.
37 bool Unzip(const FilePath& zip_file, const FilePath& dest_dir);
39 } // namespace zip
41 #endif // CHROME_COMMON_ZIP_H_