mirror of
https://git.sr.ht/~bryan_bennett/flake_env
synced 2025-12-16 14:41:24 +01:00
Fix rmrf to properly handle symlinks
This commit is contained in:
parent
bddef99967
commit
b7413a17f1
1 changed files with 12 additions and 13 deletions
|
|
@ -128,21 +128,20 @@ let get_watches = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let rec rmrf = (path) => switch (Sys_unix.is_directory(~follow_symlinks=false, path)) {
|
// TODO: Maybe make this more terse?
|
||||||
| `Yes => {
|
let rec rmrf = (path) => {
|
||||||
Sys_unix.readdir(path) |> Array.iter(~f=name => { print_endline(Filename.concat(path, name)); rmrf(Filename.concat(path, name))});
|
switch (Unix.lstat(path).st_kind) {
|
||||||
|
| S_REG => Unix.unlink(path)
|
||||||
|
| S_LNK => Unix.unlink(path)
|
||||||
|
| S_DIR => {
|
||||||
|
Sys_unix.readdir(path) |> Array.iter(~f=name => rmrf(Filename.concat(path, name)));
|
||||||
Unix.rmdir(path)
|
Unix.rmdir(path)
|
||||||
}
|
}
|
||||||
| `No => {
|
| S_CHR => Printf.eprintf("Don't know how to handle Character Device file\n")
|
||||||
switch (Sys_unix.is_file(~follow_symlinks=false, path)) {
|
| S_BLK => Printf.eprintf("Don't know how to handle Block Device file\n")
|
||||||
| `Yes => Sys_unix.remove(path)
|
| S_FIFO => Printf.eprintf("Don't know how to handle FIFO file\n")
|
||||||
| _ => ()
|
| S_SOCK => Printf.eprintf("Don't know how to handle Socket file\n")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
| `Unknown => {
|
|
||||||
Printf.eprintf("Cannot determine what file type of path %s", path);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let clean_old_gcroots = (layout_dir) => {
|
let clean_old_gcroots = (layout_dir) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue