search for: recursive_rmdir

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

Did you mean: recursive_mkdir
2014 Feb 20
4
[PATCH 1/2] mllib: add an hook to cleanup directories on exit
...n_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 -> try recursive_rmdir dir with _ -&g...