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
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
ASKER
Are there any specific call or libraries for Unix
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
ASKER
Thanks
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