1
0
Fork 0

Finish FVM package

This commit is contained in:
Florian RICHER (MrDev023) 2021-07-24 20:17:11 +02:00
parent f2bf17fde9
commit 3c390e5396
13 changed files with 178 additions and 28 deletions
src/common/utils/extractor

View file

@ -6,13 +6,7 @@ use std::{fs::{
pub fn extract_file(path: &PathBuf, outdir: &str) -> Option<()> {
let file = File::open(&path).ok()?;
let mut archive = match zip::ZipArchive::new(file) {
Ok(archive) => archive,
Err(err) => {
println!("[ERROR][EXTRACTOR] {}", err);
return None
}
};
let mut archive = zip::ZipArchive::new(file).ok()?;
let path = path::Path::new(common::TEMP_FOLDER).join(outdir);
@ -22,15 +16,8 @@ pub fn extract_file(path: &PathBuf, outdir: &str) -> Option<()> {
let output_path = path.join(file_path);
if (&*file.name()).ends_with('/') {
println!("File {} extracted to \"{}\"", i, output_path.display());
create_dir_all(&output_path).ok()?;
} else {
println!(
"File {} extracted to \"{}\" ({} bytes)",
i,
output_path.display(),
file.size()
);
if let Some(p) = output_path.parent() {
if !p.exists() {
create_dir_all(&p).ok()?;