digitalmars.D.learn - dirEntries: How get "." and ".."?
- kdevel (16/16) Jan 09 2021 Why does dirEntries in std/file.d do that (POSIX version)?:
- Anonymouse (5/8) Jan 10 2021 I imagine dirEntries returning an entry for ".." would make for a
Why does dirEntries in std/file.d do that (POSIX version)?: for (dirent* fdata; (fdata = readdir(_stack[$-1].h)) != null; ) { // Skip "." and ".." if (core.stdc.string.strcmp(&fdata.d_name[0], ".") && core.stdc.string.strcmp(&fdata.d_name[0], "..")) { _cur = DirEntry(_stack[$-1].dirpath, fdata); return true; } } There seems to be no switch to disable the skip of "." and "..". So the original position of these dir entries is lost. ☹
Jan 09 2021
On Saturday, 9 January 2021 at 18:44:10 UTC, kdevel wrote:There seems to be no switch to disable the skip of "." and "..". So the original position of these dir entries is lost. ☹I imagine dirEntries returning an entry for ".." would make for a lot of confusion. Don't you already know "." as the path you passed to dirEntries? What exactly are you trying to do?
Jan 10 2021
On Sunday, 10 January 2021 at 20:39:56 UTC, Anonymouse wrote:On Saturday, 9 January 2021 at 18:44:10 UTC, kdevel wrote:IMHO the application programmer/software engineer needs no such protection. [sarcasm deleted]There seems to be no switch to disable the skip of "." and "..". So the original position of these dir entries is lost. ☹I imagine dirEntries returning an entry for ".." would make for a lot of confusion.Don't you already know "." as the path you passed to dirEntries?I don't know the change date, the uid/gid etc.What exactly are you trying to do?I am refactoring a Filebrowser.
Jan 10 2021
On 10.01.21 23:15, kdevel via Digitalmars-d-learn wrote:Not as sexy, but can't you manually construct DirEntries [1] by supplying the paths via std.path [2]? DirName [3] should give you the current/parent directory, for example. [1] https://dlang.org/library/std/file/dir_entry.html [2] https://dlang.org/phobos/std_path.html [3] https://dlang.org/phobos/std_path.html#.dirNameDon't you already know "." as the path you passed to dirEntries?I don't know the change date, the uid/gid etc.
Jan 10 2021