File.Deprecatedval fold :
?err:(exn -> int -> string -> 'a -> 'a) ->
(int -> string -> 'a -> 'a) ->
'a ->
string ->
'a(fold ?err f init dir) folds f over all files in dir, recursively, with init as initial accumulator.
N.B. neither "." nor ".." are ever passed to f.
f is called with the depth, the complete pathname relative to the starting dir, and the accumulator; if dir is absolute, so will be all the pathnames.
The depth is 0 (only) for the starting directory dir itself, and is incremented as we descend. So all the files and directories directly contained in dir have depth 1, and so on.
An exception can be raised either by fold as it descends into directories (permission denied or bad symlink), or by f. In either case, ~err will be called, instead of f, with the exception, the depth, the pathname, and the accumulator.
In general it's preferable for f to do its own error handling.
You almost always want to handle exceptions, as there are several surprising possibilities: mode = 0, broken symlink, etc.
If ~err isn't provided, the exception will be raised and the fold terminated.
See Find for helpful combinators.
Example: collect all filenames into a list (assuming no errors):
(fold (fun d p a -> cons p a) [] ".") = (fold (fun _ -> cons) [] ".") = (fold (k cons) [] ".") = (fold Find.(igndepth cons) [] ".") = (fold Find.cons [] ".")module Find : sig ... end