let subdirs path =
let d = Unix.opendir path in
let rec iter acc =
let file =
try Some (Unix.readdir d)
with End_of_file -> Unix.closedir d; None
in
match file with
| None -> List.rev acc
| Some s when
s = Filename.current_dir_name or
s = Filename.parent_dir_name -> iter acc
| Some file ->
let complete_f = Filename.concat path file in
match
try Some (Unix.stat complete_f).Unix.st_kind
with _ -> None
with
Some Unix.S_DIR -> iter (complete_f :: acc)
| None | Some _ -> iter acc
in
iter []