D man pages

Jarek jsiebert at poczta.wp.pl
Thu Oct 10 18:52:32 UTC 2019


On Monday, 23 September 2019 at 12:31:16 UTC, Adam D. Ruppe wrote:
> On Monday, 23 September 2019 at 06:06:05 UTC, Jarek wrote:
>> I have the same question. Where to find something similar to 
>> man pages from C?
>
> They are the same functions, so the idea is you can just use 
> the C man pages directly. There's just the pattern of the D 
> module name to know.
>
> but...
>
>> does it mean that I can't use seekdir() on systems with Musl? 
>> (Alpine linux)?
>
> it is possibly just not copied in there, I'd say to just try it 
> and see if it triggers the static assert down there.
>
> the man page says
>
> CONFORMING TO
>        4.3BSD, POSIX.1-2001.
>
> so it probably should work with the core.sys.posix header 
> there, maybe it just isn't verified as to the type of the 
> argument (the notes section warns it has changed, so the D devs 
> are surely being extra cautious about which one it actually has 
> in there, waiting for someone to verify it before putting in 
> the file)

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

int main(string[] args)
{
         DIR* proc;
         dirent *ent;
         proc = opendir("/proc");
         if(proc == null)        {
                 stderr.writeln("Open /proc error");
                 return 1;
         }
         stdout.writeln("proc opened");
         while((ent = readdir(proc)) != null)    {
                 if(ent.d_type != DT_DIR)        {
                         continue;
                 }
                 stdout.writeln("Subdir: ", to!string(ent.d_name));
         }
         if(closedir(proc) == -1)        {
                 stderr.writeln("Close dir error");
                 return 1;
         }
         return 0;
}

How to handle ent.d_name? When I writeln it with to!string() 
conversion then it doesn't print well.
As a result I got something like this:
(...)
Subdir: 8�
10�11�12�13�14�15�17�18�19�
10�11�12�13�14�15�17�18�19�22�
Subdir: 10�11�12�13�14�15�17�18�19�22�23�
ubdir: 11�12�13�14�15�17�18�19�22�23�24�K
Subdir: 12�13�14�15�17�18�19�22�23�24�K25�L
Subdir: 13�14�15�17�18�19�22�23�24�K25�L73�M
Subdir: 14�15�17�18�19�22�23�24�K25�L73�M74�N
Subdir: 15�17�18�19�22�23�24�K25�L73�M74�N75�O
Subdir: 17�18�19�22�23�24�K25�L73�M74�N75�O76�Q
Subdir: 18�19�22�23�24�K25�L73�M74�N75�O76�Q77�R
Subdir: 19�22�23�24�K25�L73�M74�N75�O76�Q77�R79�S
Subdir: 22�23�24�K25�L73�M74�N75�O76�Q77�R79�S80�T
Subdir: 23�24�K25�L73�M74�N75�O76�Q77�R79�S80�T81�U
(...)
to!string() doesn't work?
thanks for help


More information about the Digitalmars-d-learn mailing list