[erlang-patches] prim_file:exists/{1,2} a new lightweight file existence check

Björn Gustavsson <>
Mon Oct 11 15:26:12 CEST 2010

On Fri, Oct 8, 2010 at 1:52 AM, Blaine Whittle <> wrote:
> This function is meant to be faster / simpler check for the existence
> of a file or directory.  Most all erlang functions that do this end
> up calling prim_file:read_file_info at some point.   When
> read_file_info is used as a simple existence check, time is wasted
> collecting file stats data only to turn around and throw the data
> away.  If a file exists, read_file_info can take three times longer
> to return than when the file doesn't exist.  Return values are true,
> false, or {error, eisdir}.  The low level implementation of this
> function was already defined via efile_may_openfile, this patch just
> exposes it to prim_file.  filelib:is_dir/1, filelib:is_file/1,
> filelib:is_regular/1 could be changed from calling read_file_info to
> prim_file:exists or better yet to calling to a yet unwritten
> file:exists function.
> Patch located at
> git fetch git://github.com/bwhittle/otp.git efile_exists

Thanks! I will include it in 'pu'.

Two source files had execution permission set in
your commit. I have fixed that. I have also removed
the commit of prim_file.beam for practical reasons
(I have put the update in a separate commit in
the 'pu' branch).

Björn Gustavsson, Erlang/OTP, Ericsson AB

More information about the erlang-patches mailing list