use flate2::write::GzEncoder;
use flate2::Compression;
use std::fs::File;
use std::path::PathBuf;
pub fn create(files: Vec<PathBuf>, destination: PathBuf) -> Result<(), ()> {
let tar_gz = File::create(destination).unwrap();
let enc = GzEncoder::new(tar_gz, Compression::best());
let mut tar = tar::Builder::new(enc);
tar.follow_symlinks(false);
for file in files {
if file.is_dir() {
tar.append_dir_all(file.strip_prefix("/").unwrap(), file.clone())
.unwrap()
} else if file.is_file() {
tar.append_path_with_name(file.clone(), file).unwrap();
}
}
Ok(())
}