mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-01 13:37:48 +00:00
mkdir: skip setting dir permissions on windows
This commit is contained in:
parent
5e1a6c1f13
commit
f592dff46a
2 changed files with 7 additions and 5 deletions
|
@ -179,6 +179,7 @@ fn chmod(_path: &Path, _mode: u32) -> UResult<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn create_dir(path: &Path, recursive: bool, verbose: bool, is_parent: bool) -> UResult<()> {
|
||||
if path.exists() && !recursive {
|
||||
return Err(USimpleError::new(
|
||||
|
@ -207,6 +208,7 @@ fn create_dir(path: &Path, recursive: bool, verbose: bool, is_parent: bool) -> U
|
|||
path.quote()
|
||||
);
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
if is_parent {
|
||||
// directories created by -p have permission bits set to '=rwx,u+wx',
|
||||
// which is umask modified by 'u+wx'
|
||||
|
|
|
@ -84,13 +84,13 @@ fn test_mkdir_parent_mode() {
|
|||
assert!(at.dir_exists("a"));
|
||||
// parents created by -p have permissions set to "=rwx,u+wx"
|
||||
assert_eq!(
|
||||
at.metadata("a").permissions().mode(),
|
||||
at.metadata("a").permissions().mode() as mode_t,
|
||||
((!default_umask & 0o777) | 0o300) + 0o40000
|
||||
);
|
||||
assert!(at.dir_exists("a/b"));
|
||||
// sub directory's permission is determined only by the umask
|
||||
assert_eq!(
|
||||
at.metadata("a/b").permissions().mode(),
|
||||
at.metadata("a/b").permissions().mode() as mode_t,
|
||||
(!default_umask & 0o777) + 0o40000
|
||||
);
|
||||
|
||||
|
@ -118,17 +118,17 @@ fn test_mkdir_parent_mode_check_existing_parent() {
|
|||
assert!(at.dir_exists("a"));
|
||||
// parent dirs that already exist do not get their permissions modified
|
||||
assert_eq!(
|
||||
at.metadata("a").permissions().mode(),
|
||||
at.metadata("a").permissions().mode() as mode_t,
|
||||
(!default_umask & 0o777) + 0o40000
|
||||
);
|
||||
assert!(at.dir_exists("a/b"));
|
||||
assert_eq!(
|
||||
at.metadata("a/b").permissions().mode(),
|
||||
at.metadata("a/b").permissions().mode() as mode_t,
|
||||
((!default_umask & 0o777) | 0o300) + 0o40000
|
||||
);
|
||||
assert!(at.dir_exists("a/b/c"));
|
||||
assert_eq!(
|
||||
at.metadata("a/b/c").permissions().mode(),
|
||||
at.metadata("a/b/c").permissions().mode() as mode_t,
|
||||
(!default_umask & 0o777) + 0o40000
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue