<html><head><meta http-equiv="Content-Type" content="text/html charset=gb2312"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hello,<div class=""><br class=""></div><div class="">By exploring the source code, I found file:list_dir/1 is implemented as a NIF, which is implemented in C.</div><div class="">And, under UNIX, it uses opendir() and readdir() to get the directory entries, dot(.) and dot-dot(..) is ignored by design.</div><div class=""><br class=""></div><div class="">The specified source code is here (efile_list_dir and is_ignored_name):</div><div class=""><a href="https://github.com/erlang/otp/blob/master/erts/emulator/nifs/unix/unix_prim_file.c#L894" class="">https://github.com/erlang/otp/blob/master/erts/emulator/nifs/unix/unix_prim_file.c#L894</a></div><div class=""><a href="https://github.com/erlang/otp/blob/master/erts/emulator/nifs/unix/unix_prim_file.c#L884" class="">https://github.com/erlang/otp/blob/master/erts/emulator/nifs/unix/unix_prim_file.c#L884</a></div><div class=""><br class=""></div><div class="">But no comment saying why dot(.) and dot-dot(..) is ignored.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Yao</div><div class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">在 2021年6月29日,08:29,Yao Bao <<a href="mailto:free7by@163.com" class="">free7by@163.com</a>> 写道:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hello,<br class=""><br class="">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.<br class=""><br class="">I would expect the result from file:list_dir/1 in Erlang is the same as readdir(dirp) in C.<br class=""><br class="">Is there any (historical) reason why these two special directories missing from the return?<br class=""><br class="">Cheers,<br class="">Yao</div></div></blockquote></div><br class=""></div></div></body></html>