Thread overview
dirEntries: How get "." and ".."?
Jan 09, 2021
kdevel
Jan 10, 2021
Anonymouse
Jan 10, 2021
kdevel
Jan 10, 2021
oddp
January 09, 2021
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. ☹
January 10, 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?
January 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:
>> 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.

IMHO the application programmer/software engineer needs no such
protection. [sarcasm deleted]

> 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.
January 11, 2021
On 10.01.21 23:15, kdevel via Digitalmars-d-learn wrote:
>> Don't you already know "." as the path you passed to dirEntries?
> 
> I don't know the change date, the uid/gid etc.

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#.dirName