Merge pull request #229 from sigmaSd/ux

Actually use relative paths when extracting
This commit is contained in:
João Marcos Bezerra 2021-12-13 22:43:14 -03:00 committed by GitHub
commit 35a158ec63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 8 deletions

View File

@ -38,7 +38,8 @@ pub fn unpack_archive(
// importance for most users, but would generate lots of
// spoken text for users using screen readers, braille displays
// 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);
}

View File

@ -1,9 +1,4 @@
use std::{
borrow::Cow,
cmp,
ffi::OsStr,
path::{Component, Path},
};
use std::{borrow::Cow, cmp, ffi::OsStr, path::Path};
/// 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.
/// If this function fails, it will return source path as a PathBuf.
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