mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 19:45:29 +00:00
Minor changes in decompressors/zip.rs
This commit is contained in:
parent
e705024c61
commit
23c8f567fc
@ -40,23 +40,25 @@ impl ZipDecompressor {
|
|||||||
|
|
||||||
Self::check_for_comments(&file);
|
Self::check_for_comments(&file);
|
||||||
|
|
||||||
if (&*file.name()).ends_with('/') {
|
let is_dir = (&*file.name()).ends_with('/');
|
||||||
|
|
||||||
|
if is_dir {
|
||||||
println!("File {} extracted to \"{}\"", idx, file_path.display());
|
println!("File {} extracted to \"{}\"", idx, file_path.display());
|
||||||
fs::create_dir_all(&file_path)?;
|
fs::create_dir_all(&file_path)?;
|
||||||
} else {
|
} else {
|
||||||
|
if let Some(p) = file_path.parent() {
|
||||||
|
if !p.exists() {
|
||||||
|
fs::create_dir_all(&p)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
println!(
|
println!(
|
||||||
"{}: \"{}\" extracted. ({} bytes)",
|
"{}: \"{}\" extracted. ({} bytes)",
|
||||||
"info".yellow(),
|
"info".yellow(),
|
||||||
file_path.display(),
|
file_path.display(),
|
||||||
file.size()
|
file.size()
|
||||||
);
|
);
|
||||||
if let Some(p) = file_path.parent() {
|
let mut outfile = fs::File::create(&file_path)?;
|
||||||
if !p.exists() {
|
io::copy(&mut file, &mut outfile)?;
|
||||||
fs::create_dir_all(&p).unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let mut outfile = fs::File::create(&file_path).unwrap();
|
|
||||||
io::copy(&mut file, &mut outfile).unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let file_path = fs::canonicalize(file_path.clone())?;
|
let file_path = fs::canonicalize(file_path.clone())?;
|
||||||
@ -76,7 +78,6 @@ impl Decompressor for ZipDecompressor {
|
|||||||
|
|
||||||
let files_unpacked = Self::unpack_files(&from.path, destination_path)?;
|
let files_unpacked = Self::unpack_files(&from.path, destination_path)?;
|
||||||
|
|
||||||
// placeholder return
|
|
||||||
Ok(files_unpacked)
|
Ok(files_unpacked)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user