let slurp_with_find path =
let find_cmd = try Sys.getenv "OCAMLBUILD_FIND" with _ -> "find" in
let lines =
My_unix.run_and_open (Printf.sprintf "%s %s" find_cmd (Filename.quote path)) begin fun ic ->
let acc = ref [] in
try while true do acc := input_line ic :: !acc done; []
with End_of_file -> !acc
end in
let res =
List.fold_right begin fun line acc ->
add path (split line) acc
end lines [] in
match res with
| [] -> Nothing
| [entry] -> entry
| entries -> Dir(path, Filename.basename path, lazy (My_unix.stat path), (), lazy entries)