Re: Correct ls/1 in c.erl
Bengt Kleberg <[email protected]>
| Newsgroups | gmane.comp.lang.erlang.patches |
|---|---|
| Organization | Ericsson AB |
| Message-ID | <[email protected]> |
6> file:list_dir("nosuchfile").
{error,enotdir}
I think to use file:read_link_info/1 to establish the existence of the
file/directory.
bengt
On Mon, 2013-05-20 at 11:00 +0200, Björn Gustavsson wrote:
> On Mon, May 20, 2013 at 10:49 AM, Bengt Kleberg
> <[email protected]> wrote:
> I will update the code and test suite according to you
> suggestions.
>
> The failure to print /dev/null is due to filelib:is_file/1 not
> thinking
> of it as a file. I will change to another method.
>
>
> It seems to me that the simplest way would be like this:
>
>
> ls(Dir) ->
> case file:list_dir(Dir) of
> {ok, Entries} ->
> ls_print(sort(Entries));
> {error, enotdir} ->
> ls_print([Dir]);
> {error, Error} ->
> format(file:format_error(Error))
> end.
>
>
> (and deleting the ls_file/2 function.)
>
>
> Do you seen any problem with that method?
>
>
>
> --
> Björn Gustavsson, Erlang/OTP, Ericsson AB
_______________________________________________
erlang-patches mailing list
[email protected]
http://erlang.org/mailman/listinfo/erlang-patches