1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-02 05:57:46 +00:00

rmdir: clean up returning Err

This commit is contained in:
Jeong YunWon 2021-06-11 14:25:17 +09:00
parent 7cc4bf6e36
commit 2dd9822d57

View file

@ -109,17 +109,14 @@ fn remove(dirs: Vec<String>, ignore: bool, parents: bool, verbose: bool) -> Resu
} }
fn remove_dir(path: &Path, ignore: bool, verbose: bool) -> Result<(), i32> { fn remove_dir(path: &Path, ignore: bool, verbose: bool) -> Result<(), i32> {
let mut read_dir = match fs::read_dir(path) { let mut read_dir = fs::read_dir(path).map_err(|e| {
Ok(m) => m, if e.raw_os_error() == Some(ENOTDIR) {
Err(e) if e.raw_os_error() == Some(ENOTDIR) => {
show_error!("failed to remove '{}': Not a directory", path.display()); show_error!("failed to remove '{}': Not a directory", path.display());
return Err(1); } else {
}
Err(e) => {
show_error!("reading directory '{}': {}", path.display(), e); show_error!("reading directory '{}': {}", path.display(), e);
return Err(1);
} }
}; 1
})?;
let mut r = Ok(()); let mut r = Ok(());