make cp can copy folders contains dangling symbolic link (#5645)

* cp with no dangling link

* add -p to not follow symbolic link

* change comment

* add one more test case to check symblink body after copied

* better help message
This commit is contained in:
WindSoilder
2022-05-26 23:42:52 +08:00
committed by GitHub
parent 50146bdef3
commit 219c719e98
3 changed files with 162 additions and 20 deletions

View File

@ -228,7 +228,9 @@ impl<'a> Playground<'a> {
pub fn within(&mut self, directory: &str) -> &mut Self {
self.cwd.push(directory);
std::fs::create_dir(&self.cwd).expect("can not create directory");
if !(self.cwd.exists() && self.cwd.is_dir()) {
std::fs::create_dir(&self.cwd).expect("can not create directory");
}
self
}