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

Tue Jun 29 10:35:28 CEST 2021

Maybe there is a philosophical reason:
A process always has a current directory (maybe except some zombies).
It is a bit like "cogito, ergo sum.". If you accept this, then it is a trivial fact that you have to be somewhere,
the short form of which is ".". There is no more reason to state it every time.
".." is a similar item. Every directory has a parent (well, nearly every directory), 
so there is also no need to include that in the results.

More important is that one can use these shortcuts in functions like file:list_dir()/1.

Am Di., Jun. 29, 2021 06:11 schrieb Yao Bao :

I'm trying to list all files in a directory, then I found file:list_dir/1, it works fine but dot(.) and dot-dot(..) is missing.

I would expect the result from file:list_dir/1 in Erlang is the same as readdir(dirp) in C.

Is there any (historical) reason why these two special directories missing from the return?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the erlang-questions mailing list