On Thursday, 10 October 2019 at 19:26:36 UTC, Daniel Kozak wrote:
On Thursday, 10 October 2019 at 19:25:22 UTC, Daniel Kozak wrote:
On Thursday, 10 October 2019 at 19:21:06 UTC, Daniel Kozak wrote:
On Thursday, 10 October 2019 at 19:19:42 UTC, Daniel Kozak wrote:
On Thursday, 10 October 2019 at 18:52:32 UTC, Jarek wrote:
On Monday, 23 September 2019 at 12:31:16 UTC, Adam D. Ruppe wrote:
[...]

Hello,
thanks for reply.
This is my first dlang work:
import std.stdio;
import std.conv;
import core.sys.posix.dirent;

[...]

You should use fromStringZ: https://dlang.org/phobos/std_string.html#.fromStringz

stdout.writeln("Subdir: ", ent.d_name.fromStringz);


One more time :)
stdout.writeln("Subdir: ", ent.d_name.ptr.fromStringz);

and to!string works too: ent.d_name.ptr.to!string

and there is a more D idiomatic version:

import std.stdio;
import std.algorithm;
import std.file;
import std.path;

int main()
{
        try
        {
                auto dFiles = dirEntries("/proc", SpanMode.shallow)
                        .filter!(f => f.isDir)
                        .each!((a){writefln("Subdir: %s", a.baseName);});
        }
        catch (FileException fe)
        {
                stderr.writeln(fe.msg);
                return 1;
        }
        return 0;               
}

Reply via email to