Compress directories

    0

    0

    Giovanny Gongora

    tarballcompress
    Codiga's Rust Recipes

    Generate a tar.gz

    extern crate tar;
    extern crate flate2;
    use std::fs::File;
    use flate2::Compression;
    use flate2::write::GzEncoder;
    
    fn main() -> Result<(), std::io::Error> {
        let tar_gz = File::create("compressed.tar.gz")?;
        let enc = GzEncoder::new(tar_gz, Compression::default());
        let mut tar = tar::Builder::new(enc);
        tar.append_dir_all("DIRECTORY_1", "DIRECTORY_1")?;
        Ok(())
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.