Skip to content

Commit 41f9ef3

Browse files
committed
added the logic for dir args and we are not moving the empty director to
the trash
1 parent 6ca2e84 commit 41f9ef3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,17 @@ fn main() {
2929

3030
// iterating over the paths
3131
for path in paths {
32+
if path.is_dir() && dir {
33+
if let Err(e) = fs::remove_dir(&path) {
34+
eprintln!("Error removing directory: {e}")
35+
}
36+
continue;
37+
}
38+
3239
if path.is_dir() && !recursive {
3340
if !force {
3441
eprintln!("rmxd: cannot remove {path:?}: Is a directory");
3542
}
36-
if dir && fs::read(&path).iter().next().is_none() {
37-
fs::remove_dir(&path).unwrap()
38-
}
3943
continue;
4044
}
4145

0 commit comments

Comments
 (0)