mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-07 20:15:27 +00:00
Actually use relative paths when extracting
This commit is contained in:
parent
9c3446924c
commit
42bcc024d4
@ -38,7 +38,8 @@ pub fn unpack_archive(
|
|||||||
// importance for most users, but would generate lots of
|
// importance for most users, but would generate lots of
|
||||||
// spoken text for users using screen readers, braille displays
|
// spoken text for users using screen readers, braille displays
|
||||||
// and so on
|
// and so on
|
||||||
info!(@display_handle, inaccessible, "{:?} extracted. ({})", output_folder.join(file.path()?), Bytes::new(file.size()));
|
|
||||||
|
info!(@display_handle, inaccessible, "{:?} extracted. ({})", utils::strip_cur_dir(&output_folder.join(file.path()?)), Bytes::new(file.size()));
|
||||||
|
|
||||||
files_unpacked.push(file_path);
|
files_unpacked.push(file_path);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
use std::{
|
use std::{borrow::Cow, cmp, ffi::OsStr, path::Path};
|
||||||
borrow::Cow,
|
|
||||||
cmp,
|
|
||||||
ffi::OsStr,
|
|
||||||
path::{Component, Path},
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Converts an OsStr to utf8 with custom formatting.
|
/// Converts an OsStr to utf8 with custom formatting.
|
||||||
///
|
///
|
||||||
@ -19,7 +14,8 @@ pub fn to_utf(os_str: impl AsRef<OsStr>) -> String {
|
|||||||
/// normally used for presentation sake.
|
/// normally used for presentation sake.
|
||||||
/// If this function fails, it will return source path as a PathBuf.
|
/// If this function fails, it will return source path as a PathBuf.
|
||||||
pub fn strip_cur_dir(source_path: &Path) -> &Path {
|
pub fn strip_cur_dir(source_path: &Path) -> &Path {
|
||||||
source_path.strip_prefix(Component::CurDir).unwrap_or(source_path)
|
let cwd = std::env::current_dir().unwrap_or_else(|_| Path::new(".").to_path_buf());
|
||||||
|
source_path.strip_prefix(cwd).unwrap_or(source_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts a slice of AsRef<OsStr> to comma separated String
|
/// Converts a slice of AsRef<OsStr> to comma separated String
|
||||||
|
Loading…
x
Reference in New Issue
Block a user