[erlang-bugs] file:path_open chokes on anything but enoent errors

Thomas Järvstrand thomas.jarvstrand@REDACTED
Fri Oct 26 11:58:21 CEST 2012


Hi!

from the file-module:

> *path_open_first([Path|Rest], Name, Mode, LastError) ->
>     case file_name(Path) of
>     {error, _} = Error ->
>         Error;
>     FilePath ->
>         FileName = fname_join(FilePath, Name),
>         case open(FileName, Mode) of
>         {ok, Fd} ->
>             {ok, Fd, FileName};
>         {error, enoent} ->
>             path_open_first(Rest, Name, Mode, LastError);
>         Error ->
>             Error
>         end
>     end;*
>

For some reason that I haven't deduced yet, my os seems to return enotdir
instead of enoent when resolving a relative include. Compiling module with
include-directives relative to the source in the shell will result in the
call file:path_open([".",
"path/to/src.erl"],"../../../relative/path/to/include", [read]), which
fails because the second path in the list is never tried due to file:open/2
returning enotdir.

I have not yet figured out why I get this return value from the c-code, but
shouldn't this be more permissive regardless? I feel that at in addition to
enoent there should at least be support for eisdir and enotdir.

Regards
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20121026/0decc373/attachment.htm>


More information about the erlang-bugs mailing list