Re: file:list_dir/1 cannot lists dot(.) and dot-dot(..) directories
Attila Rajmund Nohl <[email protected]>
| Newsgroups | gmane.comp.lang.erlang.general |
|---|---|
| Message-ID | <CAFkcMa9rGHCzqpMzymumR0HQBzQ=mzHaAHL8ZQUHP0r93zRsPQ@mail.gmail.com> |
Yao Bao <[email protected]> ezt írta (időpont: 2021. jún. 29., K, 6:11): > > Hello, > > 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? I guess it's pretty rare that you actually want to do something with the "." and ".." directory entries, so it makes sense to not return them... For example, in Perl by default the read_dir function in the File::Slurp module does not return the "." and ".." entries (there's an option to return these).