mirror of
https://github.com/sharkdp/fd.git
synced 2024-11-18 09:50:34 +01:00
Fix too many path separators on Windows (#93).
This commit is contained in:
parent
b441528067
commit
0677e6331d
1 changed files with 8 additions and 1 deletions
|
@ -3,7 +3,7 @@ use internal::{FdOptions, PathDisplay, ROOT_DIR};
|
|||
use std::{fs, process};
|
||||
use std::io::{self, Write};
|
||||
use std::ops::Deref;
|
||||
use std::path::{self, Path, PathBuf};
|
||||
use std::path::{self, Path, PathBuf, Component};
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
|
@ -42,6 +42,13 @@ pub fn print_entry(base: &Path, entry: &PathBuf, config: &FdOptions) {
|
|||
|
||||
component_path.push(Path::new(comp_str.deref()));
|
||||
|
||||
if let Component::RootDir = component {
|
||||
// Printing the root dir would result in too many path separators on Windows.
|
||||
// Note that a root dir component won't occur on Unix, because `entry` is never an
|
||||
// absolute path in that case.
|
||||
continue;
|
||||
}
|
||||
|
||||
let metadata = component_path.metadata().ok();
|
||||
let is_directory = metadata.as_ref().map(|md| md.is_dir()).unwrap_or(false);
|
||||
|
||||
|
|
Loading…
Reference in a new issue