mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 19:45:29 +00:00
Change display of current directory (#119)
This commit is contained in:
parent
49a9740e42
commit
5f7d777342
@ -19,6 +19,7 @@ use crate::{
|
||||
CompressionFormat::{self, *},
|
||||
},
|
||||
info, oof,
|
||||
utils::nice_directory_display,
|
||||
utils::to_utf,
|
||||
utils::{self, dir_is_empty},
|
||||
Error,
|
||||
@ -318,7 +319,7 @@ fn decompress_file(
|
||||
utils::create_dir_if_non_existent(output_folder)?;
|
||||
let zip_archive = zip::ZipArchive::new(reader)?;
|
||||
let _files = crate::archive::zip::unpack_archive(zip_archive, output_folder, flags)?;
|
||||
info!("Successfully decompressed archive in '{}'.", to_utf(output_folder));
|
||||
info!("Successfully decompressed archive in {}.", nice_directory_display(output_folder));
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
@ -352,31 +353,31 @@ fn decompress_file(
|
||||
let mut writer = fs::File::create(&output_path)?;
|
||||
|
||||
io::copy(&mut reader, &mut writer)?;
|
||||
info!("Successfully decompressed archive in '{}'.", to_utf(output_path));
|
||||
info!("Successfully decompressed archive in {}.", nice_directory_display(output_path));
|
||||
}
|
||||
Tar => {
|
||||
let _ = crate::archive::tar::unpack_archive(reader, output_folder, flags)?;
|
||||
info!("Successfully decompressed archive in '{}'.", to_utf(output_folder));
|
||||
info!("Successfully decompressed archive in {}.", nice_directory_display(output_folder));
|
||||
}
|
||||
Tgz => {
|
||||
let reader = chain_reader_decoder(&Gzip, reader)?;
|
||||
let _ = crate::archive::tar::unpack_archive(reader, output_folder, flags)?;
|
||||
info!("Successfully decompressed archive in '{}'.", to_utf(output_folder));
|
||||
info!("Successfully decompressed archive in {}.", nice_directory_display(output_folder));
|
||||
}
|
||||
Tbz => {
|
||||
let reader = chain_reader_decoder(&Bzip, reader)?;
|
||||
let _ = crate::archive::tar::unpack_archive(reader, output_folder, flags)?;
|
||||
info!("Successfully decompressed archive in '{}'.", to_utf(output_folder));
|
||||
info!("Successfully decompressed archive in {}.", nice_directory_display(output_folder));
|
||||
}
|
||||
Tlzma => {
|
||||
let reader = chain_reader_decoder(&Lzma, reader)?;
|
||||
let _ = crate::archive::tar::unpack_archive(reader, output_folder, flags)?;
|
||||
info!("Successfully decompressed archive in '{}'.", to_utf(output_folder));
|
||||
info!("Successfully decompressed archive in {}.", nice_directory_display(output_folder));
|
||||
}
|
||||
Tzst => {
|
||||
let reader = chain_reader_decoder(&Zstd, reader)?;
|
||||
let _ = crate::archive::tar::unpack_archive(reader, output_folder, flags)?;
|
||||
info!("Successfully decompressed archive in '{}'.", to_utf(output_folder));
|
||||
info!("Successfully decompressed archive in {}.", nice_directory_display(output_folder));
|
||||
}
|
||||
Zip => {
|
||||
eprintln!("Compressing first into .zip.");
|
||||
@ -392,7 +393,7 @@ fn decompress_file(
|
||||
|
||||
let _ = crate::archive::zip::unpack_archive(zip_archive, output_folder, flags)?;
|
||||
|
||||
info!("Successfully decompressed archive in '{}'.", to_utf(output_folder));
|
||||
info!("Successfully decompressed archive in {}.", nice_directory_display(output_folder));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,15 @@ pub fn to_utf(os_str: impl AsRef<OsStr>) -> String {
|
||||
text.trim_matches('"').to_string()
|
||||
}
|
||||
|
||||
pub fn nice_directory_display(os_str: impl AsRef<OsStr>) -> String {
|
||||
let text = to_utf(os_str);
|
||||
if text == "." {
|
||||
"current directory".to_string()
|
||||
} else {
|
||||
format!("'{}'", text)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Bytes {
|
||||
bytes: f64,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user