From 2e6cd893dcde49fbb0cf7bb8719abf0069003edb Mon Sep 17 00:00:00 2001 From: TATSUNO Yasuhiro Date: Wed, 20 Oct 2021 00:57:11 +0900 Subject: [PATCH] Omit "./" at the start of the path (#109) --- src/archive/zip.rs | 2 ++ src/utils.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/archive/zip.rs b/src/archive/zip.rs index be47ea8..67d3118 100644 --- a/src/archive/zip.rs +++ b/src/archive/zip.rs @@ -3,6 +3,7 @@ use std::{ env, fs, io::{self, prelude::*}, + path::Component, path::{Path, PathBuf}, }; @@ -47,6 +48,7 @@ where fs::create_dir_all(&path)?; } } + let file_path = file_path.strip_prefix(Component::CurDir).unwrap_or_else(|_| file_path.as_path()); info!("{:?} extracted. ({})", file_path.display(), Bytes::new(file.size())); diff --git a/src/utils.rs b/src/utils.rs index 71e0337..4a5d617 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -2,6 +2,7 @@ use std::{ cmp, env, ffi::OsStr, fs::{self, ReadDir}, + path::Component, path::{Path, PathBuf}, }; @@ -45,6 +46,7 @@ pub fn user_wants_to_overwrite(path: &Path, flags: &oof::Flags) -> crate::Result _ => {} } + let path = path.strip_prefix(Component::CurDir).unwrap_or_else(|_| path); Confirmation::new("Do you want to overwrite 'FILE'?", Some("FILE")).ask(Some(&to_utf(path))) }