tags:

views:

86

answers:

2

Hi there, this is for a small project of mine, I'm trying to set the current process working directory to the One directory up as if my current directory is ..\downloads\movies i'd like code to set the directory to ..\downloads

I know this is possible by getting the current working directory path and extracting the directory path i need from it and then do a chdir(), however this code needs to be as efficient and light as possible, and i find the above method kinda cumbersome.

Thanks in advance falks.

+6  A: 

How simple and efficient are you looking to be? Something like

if (chdir("..") < 0)
{
    perror("chdir");
    exit(1);
}
Duck
This is using the POSIX API from `unistd.h`, FYI.
bta
Thanks you guys, never occurred to me :)
RodD
+4  A: 

Hi RodD,

U can try doing something like this

chdir("..");

Santi! :)

Santos