Finish FVM package
This commit is contained in:
parent
f2bf17fde9
commit
3c390e5396
13 changed files with 178 additions and 28 deletions
src/common/utils/extractor
|
@ -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()?;
|
||||
|
|
Reference in a new issue