Skip to content

Commit 5aebfa9

Browse files
committed
refactor(uu/rm): simplify device skipping logic by removing wrapper function
Remove the cfg-specific `should_skip_different_device` wrapper and directly call `should_skip_different_device_with_dev` with a `#[cfg(unix)]` attribute in the recursive directory removal function, reducing code duplication and improving clarity.
1 parent 71cc702 commit 5aebfa9

1 file changed

Lines changed: 2 additions & 21 deletions

File tree

src/uu/rm/src/rm.rs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -611,26 +611,6 @@ fn is_writable(_path: &Path) -> bool {
611611
true
612612
}
613613

614-
#[cfg(unix)]
615-
fn should_skip_different_device(
616-
parent_dev_id: Option<u64>,
617-
metadata: &Metadata,
618-
options: &Options,
619-
path: &Path,
620-
) -> bool {
621-
should_skip_different_device_with_dev(parent_dev_id, metadata.dev(), options, path)
622-
}
623-
624-
#[cfg(not(unix))]
625-
fn should_skip_different_device(
626-
_parent_dev_id: Option<u64>,
627-
_metadata: &Metadata,
628-
_options: &Options,
629-
_path: &Path,
630-
) -> bool {
631-
false
632-
}
633-
634614
#[cfg(unix)]
635615
fn should_skip_different_device_with_dev(
636616
parent_dev_id: Option<u64>,
@@ -759,7 +739,8 @@ fn remove_dir_recursive_with_metadata(
759739
}
760740

761741
// Base case 3: this is a directory on a different device
762-
if should_skip_different_device(parent_dev_id, metadata, options, path) {
742+
#[cfg(unix)]
743+
if should_skip_different_device_with_dev(parent_dev_id, metadata.dev(), options, path) {
763744
return true;
764745
}
765746

0 commit comments

Comments
 (0)