aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/ocamllibdep.mll
diff options
context:
space:
mode:
authorGravatar Guillaume Melquiond <guillaume.melquiond@inria.fr>2015-12-14 10:44:22 +0100
committerGravatar Guillaume Melquiond <guillaume.melquiond@inria.fr>2015-12-14 10:44:22 +0100
commitd58957f63d36e2da41f6f839a2d94cb0db4c8125 (patch)
tree884b79ab00b0b914a4fa2c3335491927eaf86a17 /tools/ocamllibdep.mll
parent7ae0748586fe8291f0666cce7bd39d7109471d08 (diff)
Remove some occurrences of Unix.opendir.
Diffstat (limited to 'tools/ocamllibdep.mll')
-rw-r--r--tools/ocamllibdep.mll25
1 files changed, 8 insertions, 17 deletions
diff --git a/tools/ocamllibdep.mll b/tools/ocamllibdep.mll
index 4e5edcf6c..1bcbe7c0e 100644
--- a/tools/ocamllibdep.mll
+++ b/tools/ocamllibdep.mll
@@ -98,23 +98,14 @@ let file_name s = function
type dir = string option
-(* Visits all the directories under [dir], including [dir],
- or just [dir] if [recur=false] *)
-
-let rec add_directory add_file phys_dir =
- let dirh = opendir phys_dir in
- try
- while true do
- let f = readdir dirh in
- (* we avoid all files and subdirs starting by '.' (e.g. .svn),
- plus CVS and _darcs and any subdirs given via -exclude-dirs *)
- if f.[0] <> '.' then
- let phys_f = if phys_dir = "." then f else phys_dir//f in
- match try (stat phys_f).st_kind with _ -> S_BLK with
- | S_REG -> add_file phys_dir f
- | _ -> ()
- done
- with End_of_file -> closedir dirh
+let add_directory add_file phys_dir =
+ Array.iter (fun f ->
+ (* we avoid all files starting by '.' *)
+ if f.[0] <> '.' then
+ let phys_f = if phys_dir = "." then f else phys_dir//f in
+ match try (stat phys_f).st_kind with _ -> S_BLK with
+ | S_REG -> add_file phys_dir f
+ | _ -> ()) (Sys.readdir phys_dir)
let error_cannot_parse s (i,j) =
Printf.eprintf "File \"%s\", characters %i-%i: Syntax error\n" s i j;