[gameprogrammer] Re: Linux equivalent of CreateDirectory

  • From: "Alan Wolfe" <atrix2@xxxxxxx>
  • To: <gameprogrammer@xxxxxxxxxxxxx>
  • Date: Sat, 10 Jul 2004 10:46:50 -0700

system("md MyDirectory");

md isnt a function, but you can use system() to create directories in
windows as well.

however, when you use system(), whatever command you pass to it is issued
from the current directory.

that means if you wanted to create the directory ./art/gui/ you could create
art but not the gui sub directory.

there is a way around it though, there is a function to change the current
directory.

in windows it's called _chdir() and you have to #include <direct.h>.
in linux etc it's called chdir() and i believe you just have to #include
<stdio.h> but i could be wrong there.

so if you wanted to create ./art/gui you would...

---linux code---
system("md art");  //make the art directory
chdir("art");          //go into the art directory
system("md gui"); //make the gui directory
chdir("..");            //go back out a directory so we are at our game's
base directory again

---windows code---
system("md art");  //make the art directory
_chdir("art");          //go into the art directory
system("md gui"); //make the gui directory
_chdir("..");            //go back out a directory so we are at our game's
base directory again

hope that helps! (i'm thinkin im gonna toss this in the wiki too)


----- Original Message ----- 
From: "Kevin Jenkins" <gameprogrammer@xxxxxxxxxx>
To: <gameprogrammer@xxxxxxxxxxxxx>
Sent: Saturday, July 10, 2004 10:27 AM
Subject: [gameprogrammer] Re: Linux equivalent of CreateDirectory


> How would I use this in code?
>
> ----- Original Message -----
> From: "Alan Wolfe" <atrix2@xxxxxxx>
> To: <gameprogrammer@xxxxxxxxxxxxx>
> Sent: Saturday, July 10, 2004 10:34 AM
> Subject: [gameprogrammer] Re: Linux equivalent of CreateDirectory
>
>
> > md for make directory
> >
> > ----- Original Message -----
> > From: "Kevin Jenkins" <gameprogrammer@xxxxxxxxxx>
> > To: <gameprogrammer@xxxxxxxxxxxxx>
> > Sent: Saturday, July 10, 2004 10:23 AM
> > Subject: [gameprogrammer] Linux equivalent of CreateDirectory
> >
> >
> > > I need to do an fopen(path, "wb") where path includes directories that
> may
> > > or may not exist.  On windows I use CreateDirectory to create the
> > > directories first, then do the fopen for the file.
> > >
> > > What is the Linux / Unix equivalent?
>
> >
> > ---------------------
> > To unsubscribe go to http://gameprogrammer.com/mailinglist.html
> >
> >
> >
> >
>
>
>
> ---------------------
> To unsubscribe go to http://gameprogrammer.com/mailinglist.html
>
>



---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: