search for: unlink_dirs

Displaying 1 result from an estimated 1 matches for "unlink_dirs".

2014 Feb 20
4
[PATCH 1/2] mllib: add an hook to cleanup directories on exit
...9ede6 100644 --- a/mllib/common_utils.ml +++ b/mllib/common_utils.ml @@ -386,6 +386,35 @@ let unlink_on_exit = registered_handlers := true ) +(* Remove a temporary directory on exit. *) +let rmdir_on_exit = + let dirs = ref [] in + let registered_handlers = ref false in + + let rec unlink_dirs () = + let rec recursive_rmdir fn = + if Sys.is_directory fn then ( + let names = Array.map (fun d -> fn // d) (Sys.readdir fn) in + Array.iter recursive_rmdir names; + Unix.rmdir fn + ) else + Unix.unlink fn + in + List.iter ( + fun dir ->...