Fix cp bug (#5462)

* Cleanup - remove old commented code

* Force a / or \ to distinguish between folders and files for cp

* Force a / or \ to distinguish between folders and files for cp

* Remove unneeded code

* Add cp test for checking copy to non existing directory

* Fix warning in test
This commit is contained in:
Stefan Stanciulescu
2022-05-20 14:49:29 -07:00
committed by GitHub
parent aa88449f29
commit 2cc5952c37
3 changed files with 30 additions and 179 deletions

View File

@ -14,6 +14,9 @@ fn expand_tilde_with_home(path: impl AsRef<Path>, home: Option<PathBuf>) -> Path
};
}
let path_last_char = path.as_os_str().to_string_lossy().chars().last();
let need_trailing_slash = path_last_char == Some('/') || path_last_char == Some('\\');
match home {
None => path.into(),
Some(mut h) => {
@ -31,6 +34,10 @@ fn expand_tilde_with_home(path: impl AsRef<Path>, home: Option<PathBuf>) -> Path
if p != Path::new("") {
h.push(p)
}
if need_trailing_slash {
h.push("");
}
}
h
}