Re: file:list_dir/1 cannot lists dot(.) and dot-dot(..) directories

Nicolas Martyanoff <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <[email protected]>
Ivan Uemlianin <[email protected]> writes:

> Python doesn't include '.' or '..' either:
>
>>>> import os
>>>> '.' in os.listdir()
> False
>>>> '..' in os.listdir()
> False
>
> Although you are able use them for example to list the content of a directory:
>
>>>> x = os.listdir()
>>>> os.chdir('..')
>>>> x == os.listdir()
> False
>
> Erlang's behaviour is similar:
>
> 1> {ok, Fs} = file:list_dir(D).
> {ok,[<filenames>]}
> 2> lists:member(".", Fs).
> false
> 3> lists:member("..", Fs).
> false
>
> 4> file:list_dir("..").
> {ok,[<filenames>]}
>

Ah yes, my bad; . and .. should be usable as any other file, but
including them when listing directories is a matter of preference.

-- 
Nicolas Martyanoff
http://snowsyn.net
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.