www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - chmod and chown in D

reply J3nkl3r <j3nkl3r askme.com> writes:
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
Jun 11 2008
parent reply Jacob Carlborg <doobnet gmail.com> writes:
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
Jun 11 2008
parent Regan Heath <regan netmail.co.nz> writes:
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
Jun 12 2008