1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

mkdir: Silently fail in recursive mode if unable to create directories.

This commit is contained in:
Connor E 2018-05-01 12:07:23 +01:00
parent 5f9bb70422
commit e03ab6b554

View file

@ -94,10 +94,10 @@ fn exec(dirs: Vec<String>, recursive: bool, mode: u16, verbose: bool) -> i32 {
let path = Path::new(dir);
if recursive {
let mut pathbuf = PathBuf::new();
if !path.is_dir() {
for component in path.components() {
pathbuf.push(component.as_os_str());
if !path.is_dir() {
status |= mkdir(pathbuf.as_path(), mode, verbose);
mkdir(pathbuf.as_path(), recursive, mode, verbose);
}
}
} else {
@ -110,11 +110,11 @@ fn exec(dirs: Vec<String>, recursive: bool, mode: u16, verbose: bool) -> i32 {
);
status = 1;
} else {
status |= mkdir(path, mode, verbose);
status |= mkdir(path, recursive, mode, verbose);
}
}
None => {
status |= mkdir(path, mode, verbose);
status |= mkdir(path, recursive, mode, verbose);
}
}
}
@ -125,9 +125,11 @@ fn exec(dirs: Vec<String>, recursive: bool, mode: u16, verbose: bool) -> i32 {
/**
* Wrapper to catch errors, return 1 if failed
*/
fn mkdir(path: &Path, mode: u16, verbose: bool) -> i32 {
fn mkdir(path: &Path, recursive: bool, mode: u16, verbose: bool) -> i32 {
if let Err(e) = fs::create_dir(path) {
if !recursive {
show_info!("{}: {}", path.display(), e.to_string());
}
return 1;
}