From: Claudio Sacerdoti Coen Date: Tue, 18 Jul 2006 11:39:18 +0000 (+0000) Subject: rmdir_descend now works also on non existent dirs X-Git-Tag: 0.4.95@7852~1196 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=c841003adea545c1bf12619906f1c61711a75deb;p=helm.git rmdir_descend now works also on non existent dirs --- diff --git a/components/extlib/hExtlib.ml b/components/extlib/hExtlib.ml index b36a4d89d..32f33bd2b 100644 --- a/components/extlib/hExtlib.ml +++ b/components/extlib/hExtlib.ml @@ -314,13 +314,16 @@ let find ?(test = fun _ -> true) path = let safe_remove fname = if Sys.file_exists fname then Sys.remove fname let is_dir_empty d = - let od = Unix.opendir d in - let rec aux () = - let name = Unix.readdir od in - if name <> "." && name <> ".." then false else aux () in - let res = try aux () with End_of_file -> true in - Unix.closedir od; - res + try + let od = Unix.opendir d in + let rec aux () = + let name = Unix.readdir od in + if name <> "." && name <> ".." then false else aux () in + let res = try aux () with End_of_file -> true in + Unix.closedir od; + res + with + Unix.Unix_error _ -> true (* raised by Unix.opendir, we hope :-) *) let safe_rmdir d = try Unix.rmdir d with Unix.Unix_error _ -> ()