diff options
author | Piotr Wach <pwach@bloomberg.net> | 2023-12-06 00:07:38 +0000 |
---|---|---|
committer | Piotr Wach <pwach@bloomberg.net> | 2023-12-06 00:08:09 +0000 |
commit | e9fb2fda3478fefa38bdb9d176380bae5545dbc6 (patch) | |
tree | 3cb9b9a9ca3654f81c85804286ea79943cdf7cd9 | |
parent | dd523e389bcc940a5d3e72099bb0c76f40371164 (diff) |
Skip through single root directory
-rw-r--r-- | src/main.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 2aac48c..ca16302 100644 --- a/src/main.rs +++ b/src/main.rs @@ -126,11 +126,16 @@ fn main() -> Result<()> { process::exit(res.to_exit_code()); } -fn paths_from(paths: Vec<PathBuf>, cross_filesystems: bool) -> Result<Vec<PathBuf>, io::Error> { +fn paths_from(mut paths: Vec<PathBuf>, cross_filesystems: bool) -> Result<Vec<PathBuf>, io::Error> { let device_id = std::env::current_dir() .ok() .and_then(|cwd| crossdev::init(&cwd).ok()); + if paths.len() == 1 { + std::env::set_current_dir(&paths[0])?; + paths.remove(0); + } + if paths.is_empty() { cwd_dirlist().map(|paths| match device_id { Some(device_id) if !cross_filesystems => paths |