Decompress file

    0

    0

    Giovanny Gongora

    Codiga's Rust Recipes

    Decompres tarball in current folder

    extern crate tar;
    extern crate flate2;
    use std::fs::File;
    use flate2::Compression;
    use flate2::write::GzEncoder;
    
    fn main() -> Result<(), std::io::Error> {
      let path = "compressed.tar.gz";
      let tar_gz = File::open(path)?;
      let tar = GzDecoder::new(tar_gz);
      let mut archive = Archive::new(tar);
      archive.unpack(".")?;
      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.