Skip to content

Commit

Permalink
Small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
AnirbanHalder654322 committed Sep 10, 2024
1 parent c6a9e66 commit 2f2680c
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions src/uu/mkdir/src/mkdir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,31 +222,30 @@ fn create_dir(
);
}

// TODO: Make this macos and freebsd compatible by creating a function to get permission bits from
// acl in extended attributes
#[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "freebsd")))]
if !path_exists {
#[cfg(all(unix, target_os = "linux"))]
let new_mode = if !path_exists {
// TODO: Make this macos and freebsd compatible by creating a function to get permission bits from
// acl in extended attributes
let acl_perm_bits = uucore::fsxattr::get_acl_perm_bits_from_xattr(path);
let new_mode = if is_parent {
(!mode::get_umask() & 0o777) | 0o300
} else {
mode
};
chmod(path, new_mode | acl_perm_bits)?;
}
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
{
let new_mode = if is_parent {
(!mode::get_umask() & 0o777) | 0o300
} else {
mode
};
chmod(path, new_mode)?;
}

if is_parent {
(!mode::get_umask() & 0o777) | 0o300 | acl_perm_bits
} else {
mode | acl_perm_bits
}
} else {
mode
};
#[cfg(all(unix, not(target_os = "linux")))]
let new_mode = if is_parent {
(!mode::get_umask() & 0o777) | 0o300
} else {
mode
};
#[cfg(windows)]
chmod(path, mode)?;
let new_mode = mode;

chmod(path, new_mode)?;
Ok(())
}

Expand Down

0 comments on commit 2f2680c

Please sign in to comment.