[erlang-questions] Fast directory walker
Mikael Pettersson
mikpelinux@REDACTED
Sat Dec 10 15:30:05 CET 2016
Stanislaw Klekot writes:
> On Fri, Dec 09, 2016 at 11:15:58PM +0000, Frank Muller wrote:
> > I would like to improve the speed of my directory walker.
> >
> > walk(Dir) ->
> > {ok, Files} = prim_file:list_dir(Dir),
> > walk(Dir, Files).
>
> Why prim_file:list_dir() instead of file:list_dir()? The former is
> undocumented internal function.
list_dir can be a very time-consuming operation, and in those cases
using file:list_dir would block the single file server for everything
else. We routinely use prim_file:list_dir to reduce the negative
effects of accessing large directories.
More information about the erlang-questions
mailing list