www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to make a directory?

reply "Minas" <minas_mina1990 hotmail.co.uk> writes:
What is the D way to create a directory?

I can use the C function system("mkdir ...") but it doesn't seem 
very good to me.

Also, is there a way to require the root password of the user 
when going create the directory in a restricted folder (like 
/usr) AFTER the application has started?

Thank you.
May 01 2012
next sibling parent reply =?UTF-8?B?QWxleCBSw7hubmUgUGV0ZXJzZW4=?= <xtzgzorex gmail.com> writes:
On 02-05-2012 01:45, Minas wrote:
 What is the D way to create a directory?

 I can use the C function system("mkdir ...") but it doesn't seem very
 good to me.
It's not in the most obvious of places: http://dlang.org/phobos/std_file.html#mkdir (But then again, an std.directory module would probably be a bit overkill...)
 Also, is there a way to require the root password of the user when going
 create the directory in a restricted folder (like /usr) AFTER the
 application has started?
No idea, sorry.
 Thank you.
-- - Alex
May 01 2012
parent Kevin Cox <kevincox.ca gmail.com> writes:
On May 1, 2012 7:49 PM, "Alex R=C3=B8nne Petersen" <xtzgzorex gmail.com> wr=
ote:
 Also, is there a way to require the root password of the user when going
 create the directory in a restricted folder (like /usr) AFTER the
 application has started?
No idea, sorry.
 Thank you.
-- - Alex
You could execute a system command and change your apps privileges but this is a bad/risky way to do it. I would use sudo or gksudo and launch the command externally so that you don't grant your app root permissions and then do something stupid. If those actions are common I would only allow root to use your app.
May 01 2012
prev sibling parent Jordi Sayol <g.sayol yahoo.es> writes:
Al 02/05/12 01:45, En/na Minas ha escrit:
[...]
 Also, is there a way to require the root password of the user when going
create the directory in a restricted folder (like /usr) AFTER the application
has started?
In Linux, files and directories have the "setuid" and "setgid" special flags that allow ordinary users to execute binaries with temporary privileges of binary file owner or group. i.e., /usr/bin/passwd (owns root, with setuid) modifies /etc/passwd by any user without write permission. /bin/ping (owns root, with setuid) allows any user to send and listen control packages throw net interfaces. -- Jordi Sayol
May 01 2012