let rec walk_dir dir func arg =
dir_iter dir
(fun d l a ->
(* Split into dirs and files *)
let (dirs, files) =
List.partition (fun x -> isdir (Filename.concat d x)) l in
(* Recurse through the dirs *)
List.iter (fun x -> walk_dir (Filename.concat d x) func arg) dirs;
(* And then process the files *)
func d files arg)
arg