Skip to content

Commit

Permalink
Merge pull request #229 from sigmaSd/ux
Browse files Browse the repository at this point in the history
Actually use relative paths when extracting
  • Loading branch information
marcospb19 authored Dec 14, 2021
2 parents a3d3e5d + 42bcc02 commit 35a158e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/archive/tar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
10 changes: 3 additions & 7 deletions src/utils/formatting.rs
Original file line number Diff line number Diff line change
@@ -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.
///
Expand All @@ -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
Expand Down

0 comments on commit 35a158e

Please sign in to comment.