diff --git a/src/lib.rs b/src/lib.rs index 02f7321..9222daa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -200,13 +200,13 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> Result PathBuf { + fn to_scope(p: &Path) -> Box { // FIXME handle volume relative paths here - p.to_path_buf() + p.into() } #[cfg(not(windows))] - fn to_scope(p: &Path) -> PathBuf { - p.to_path_buf() + fn to_scope(p: &Path) -> Box { + p.into() } // make sure that the pattern is valid first, else early return with error @@ -243,7 +243,7 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> Result, is_directory: bool, file_name: Option>, } impl PathWrapper { - fn from_dir_entry(path: PathBuf, file_name: Option>, e: DirEntry) -> Self { + fn from_dir_entry(path: Box, file_name: Option>, e: DirEntry) -> Self { let is_directory = e .file_type() .ok() @@ -355,7 +355,7 @@ impl PathWrapper { file_name, } } - fn from_path(path: PathBuf) -> Self { + fn from_path(path: Box) -> Self { let is_directory = fs::metadata(&path).map(|m| m.is_dir()).unwrap_or(false); let file_name = path.file_name().map(Box::from); Self { @@ -366,7 +366,7 @@ impl PathWrapper { } fn into_path(self) -> PathBuf { - self.path + self.path.into_path_buf() } } @@ -928,7 +928,7 @@ fn fill_todo( } else { path.join(&s) }; - let next_path = PathWrapper::from_path(next_path); + let next_path = PathWrapper::from_path(next_path.into_boxed_path()); if (special && is_dir) || (!special && (fs::metadata(&next_path).is_ok() @@ -944,9 +944,9 @@ fn fill_todo( let (path, file_name) = if curdir { let path = e.path(); let file_name = path.file_name().unwrap(); - (PathBuf::from(file_name), Some(Box::from(file_name))) + (Box::from(file_name.as_ref()), Some(Box::from(file_name))) } else { - let path = e.path(); + let path = e.path().into_boxed_path(); let file_name = path.file_name().map(Box::from); (path, file_name) }; @@ -972,7 +972,10 @@ fn fill_todo( if !pattern.tokens.is_empty() && pattern.tokens[0] == Char('.') { for &special in &[".", ".."] { if pattern.matches_with(special, options) { - add(todo, PathWrapper::from_path(path.join(special))); + add( + todo, + PathWrapper::from_path(path.join(special).into_boxed_path()), + ); } } }