pub fn render_to_zip(&self, zip_file: impl AsRef<Path>) {
        let zip_file = File::create(zip_file).unwrap();
        let mut zip = zip::ZipWriter::new(zip_file);
        let options = zip::write::FileOptions::default()
            .compression_method(zip::CompressionMethod::Deflated)
            .unix_permissions(0o755);
        let mut buffer = Vec::new();
        for mut w in self.walk_virtual_files() {
            if w.is_dir {
                if w.path.as_os_str().is_empty() {
                    // Ignore root.
                    continue;
                }
                // The "dir" case is important for empty directories only. See comment below.
                zip.add_directory_from_path(&w.path, options).unwrap();
            } else {
                // When file sets are used, it's possible that the walker visits files whose
                // parent directory has not been visited. That's not an issue when creating the ZIP
                // archive. The directory will be created automatically.
                zip.start_file_from_path(&w.path, options).unwrap();
                w.reader.read_to_end(&mut buffer).unwrap();
                zip.write_all(&*buffer).unwrap();
                buffer.clear();
            }
        }
    }
/// Creates this directory structure as a ZIP file.
Creates this directory structure as a ZIP file.
Creates this directory structure as a ZIP file .
pub fn render_to_zip(&self, zip_file: impl AsRef<Path>) {
        let zip_file = File::create(zip_file).unwrap();
        let mut zip = zip::ZipWriter::new(zip_file);
        let options = zip::write::FileOptions::default()
            .compression_method(zip::CompressionMethod::Deflated)
            .unix_permissions(0o755);
        let mut buffer = Vec::new();
        for mut w in self.walk_virtual_files() {
            if w.is_dir {
                if w.path.as_os_str().is_empty() {
                    // Ignore root.
                    continue;
                }
                // The "dir" case is important for empty directories only. See comment below.
                zip.add_directory_from_path(&w.path, options).unwrap();
            } else {
                // When file sets are used, it's possible that the walker visits files whose
                // parent directory has not been visited. That's not an issue when creating the ZIP
                // archive. The directory will be created automatically.
                zip.start_file_from_path(&w.path, options).unwrap();
                w.reader.read_to_end(&mut buffer).unwrap();
                zip.write_all(&*buffer).unwrap();
                buffer.clear();
            }
        }
    }
pub fn render_to_zip ( & self , zip_file : impl AsRef < Path > ) { let zip_file = File :: create ( zip_file ) . unwrap ( ) ; let mut zip = zip :: ZipWriter :: new ( zip_file ) ; let options = zip :: write :: FileOptions :: default ( ) . compression_method ( zip :: CompressionMethod :: Deflated ) . unix_permissions ( 0o755 ) ; let mut buffer = Vec :: new ( ) ; for mut w in self . walk_virtual_files ( ) { if w . is_dir { if w . path . as_os_str ( ) . is_empty ( ) { // Ignore root. continue ; } // The "dir" case is important for empty directories only. See comment below. zip . add_directory_from_path ( & w . path , options ) . unwrap ( ) ; } else { // When file sets are used, it's possible that the walker visits files whose // parent directory has not been visited. That's not an issue when creating the ZIP // archive. The directory will be created automatically. zip . start_file_from_path ( & w . path , options ) . unwrap ( ) ; w . reader . read_to_end ( & mut buffer ) . unwrap ( ) ; zip . write_all ( & * buffer ) . unwrap ( ) ; buffer . clear ( ) ; } } }
Creates this directory structure as a ZIP file.
Creates this directory structure as a ZIP file .
&self
zip_file
impl AsRef<Path>