Link to home
Start Free TrialLog in
Avatar of W122498
W122498

asked on

C++ and Directory Manipulation

Hi
I want to manipulate directories, thru my C++ code. Like create, delete and rename directories. This has to done for both Unix and Windows.
Is there any API or any other way of doing it?

thanks
Avatar of abdij
abdij

Hi,
   I beleive no. I donot think you can have a singlr souce code to do it. You have to follow one methodology for Windows and another for unix.

You can differentiate it this way:
#ifdef __unix
  bUnix = true;
#else
  bUnix = false;
#endif

where bUnix is a boolean flag.

Then based on the bUnix flag use OS specific calls to manipulate directory.

Bye
Abdij
Avatar of W122498

ASKER

Are there any specific call or libraries for Unix
ASKER CERTIFIED SOLUTION
Avatar of AlexVirochovsky
AlexVirochovsky

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,
 Here is what you want.

#include <dir.h>

int chdir(char *path) - Change current directory to given path.

char *getcwd(char *path, int numchars) - Returns name of current working directory.

int mkdir(char *path) - Create a directory u sing given path name.

int rmdir(char *path) - Delete a specified directory.

Hope this is what you wanted.
Bye
All the best.

Abdij



****************************************
God,
  Already answered!!!!
  Any way All the best. Just remember its not me who has answered the question!

Bye
Abdij
Avatar of W122498

ASKER

Thanks