chmod and chown in D
Regan Heath
regan at netmail.co.nz
Thu Jun 12 03:56:10 PDT 2008
Jacob Carlborg wrote:
> J3nkl3r wrote:
>> Hi all
>> i am trying out gdc and the d lang. Does anyone know how to fix chmod
>> and chown
>> c has sys/stat.h but i don't understand how i can fix chmod in d
>>
>> I want to make a chmod program in D
>>
>> regards
>> /J3nkl3r
>
> The alternative community developed runtime library Tango has a module
> for sys/stat.h.
>
> http://www.dsource.org/projects/tango/docs/current/tango.stdc.posix.sys.stat.html
>
> http://www.dsource.org/projects/tango/wiki/Download
For those who are interested in how you go about doing it or yourself
sys/stat is a fairly simple example to use to describe the process :)
So, have a look at the tango source itself:
http://www.dsource.org/projects/tango/browser/trunk/tango/stdc/posix/sys/stat.d
You'll see that in general if you want to access C functions in D you
need to define them in a D module using "extern (C)".
You need to define any structures they use, constant values they use,
and either import definitions for types they use or define them yourself.
You get all this information from the C headers, you can generally
copy/paste into your D module and then get it working with often only
minor changes.
Regan Heath
More information about the Digitalmars-d-learn
mailing list