pub fn render_to_tar_gz(&self, archive_path: impl AsRef<Path>) {
        let archive_file = File::create(archive_path).unwrap();
        let enc = GzEncoder::new(archive_file, flate2::Compression::default());
        let mut tar = tar::Builder::new(enc);
        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.
                let mut header = Header::new_gnu();
                header.set_entry_type(EntryType::Directory);
                header.set_mode(0o755);
                header.set_size(0);
                tar.append_data(&mut header, w.path, io::empty()).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 tar
                // archive. The directory will be created automatically.
                w.reader.read_to_end(&mut buffer).unwrap();
                let mut header = Header::new_gnu();
                header.set_entry_type(EntryType::Regular);
                header.set_mode(0o644);
                header.set_size(buffer.len() as _);
                tar.append_data(&mut header, w.path, buffer.as_slice())
                    .unwrap();
                buffer.clear();
            }
        }
        tar.finish().unwrap();
    }
/// Creates this directory structure as a gzipped tarball.
Creates this directory structure as a gzipped tarball.
Creates this directory structure as a gzipped tarball .
pub fn render_to_tar_gz(&self, archive_path: impl AsRef<Path>) {
        let archive_file = File::create(archive_path).unwrap();
        let enc = GzEncoder::new(archive_file, flate2::Compression::default());
        let mut tar = tar::Builder::new(enc);
        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.
                let mut header = Header::new_gnu();
                header.set_entry_type(EntryType::Directory);
                header.set_mode(0o755);
                header.set_size(0);
                tar.append_data(&mut header, w.path, io::empty()).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 tar
                // archive. The directory will be created automatically.
                w.reader.read_to_end(&mut buffer).unwrap();
                let mut header = Header::new_gnu();
                header.set_entry_type(EntryType::Regular);
                header.set_mode(0o644);
                header.set_size(buffer.len() as _);
                tar.append_data(&mut header, w.path, buffer.as_slice())
                    .unwrap();
                buffer.clear();
            }
        }
        tar.finish().unwrap();
    }
pub fn render_to_tar_gz ( & self , archive_path : impl AsRef < Path > ) { let archive_file = File :: create ( archive_path ) . unwrap ( ) ; let enc = GzEncoder :: new ( archive_file , flate2 :: Compression :: default ( ) ) ; let mut tar = tar :: Builder :: new ( enc ) ; 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. let mut header = Header :: new_gnu ( ) ; header . set_entry_type ( EntryType :: Directory ) ; header . set_mode ( 0o755 ) ; header . set_size ( 0 ) ; tar . append_data ( & mut header , w . path , io :: empty ( ) ) . 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 tar // archive. The directory will be created automatically. w . reader . read_to_end ( & mut buffer ) . unwrap ( ) ; let mut header = Header :: new_gnu ( ) ; header . set_entry_type ( EntryType :: Regular ) ; header . set_mode ( 0o644 ) ; header . set_size ( buffer . len ( ) as _ ) ; tar . append_data ( & mut header , w . path , buffer . as_slice ( ) ) . unwrap ( ) ; buffer . clear ( ) ; } } tar . finish ( ) . unwrap ( ) ; }
Creates this directory structure as a gzipped tarball.
Creates this directory structure as a gzipped tarball .
&self
archive_path
impl AsRef<Path>