From d7d218743dc1e4793a49b0aa95e752e740c2a9c3 Mon Sep 17 00:00:00 2001 From: eugenesvk Date: Wed, 4 Dec 2024 13:34:15 +0700 Subject: [PATCH] remove automatic panicky conversion of potentially binary paths into non-binary strings Issue: #124 --- src/macos.rs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/macos.rs b/src/macos.rs index 3aed6d5..595e361 100644 --- a/src/macos.rs +++ b/src/macos.rs @@ -62,10 +62,9 @@ impl TrashContextExtMacos for TrashContext { } impl TrashContext { pub(crate) fn delete_all_canonicalized(&self, full_paths: Vec) -> Result<(), Error> { - let full_paths = full_paths.into_iter().map(to_string).collect::, _>>()?; match self.platform_specific.delete_method { - DeleteMethod::Finder => delete_using_finder(full_paths), - DeleteMethod::NsFileManager => delete_using_file_mgr(full_paths), + DeleteMethod::Finder => delete_using_finder(&full_paths), + DeleteMethod::NsFileManager => delete_using_file_mgr(&full_paths), } } } @@ -126,15 +125,6 @@ fn delete_using_finder(full_paths: Vec) -> Result<(), Error> { Ok(()) } -fn to_string>(str_in: T) -> Result { - let os_string = str_in.into(); - let s = os_string.to_str(); - match s { - Some(s) => Ok(s.to_owned()), - None => Err(Error::ConvertOsString { original: os_string }), - } -} - use std::borrow::Cow; use percent_encoding::percent_encode_byte as b2pc; fn from_utf8_lossy_pc(v:&[u8]) -> Cow<'_, str> { // std's from_utf8_lossy, but non-utf8 byte sequences are %-encoded instead of being replaced by an special symbol. Valid utf8, including `%`, are not escaped, so this is still lossy. Useful for macOS file paths.