[erlang-patches] Correct ls/1 in c.erl

Björn Gustavsson <>
Mon May 20 11:00:58 CEST 2013


On Mon, May 20, 2013 at 10:49 AM, Bengt Kleberg
<>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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20130520/2e8c1609/attachment.html>


More information about the erlang-patches mailing list