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
W122498Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

abdijCommented:
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
0
W122498Author Commented:
Are there any specific call or libraries for Unix
0
AlexVirochovskyCommented:
Use such function:(BC for unix/windows)
mkdir:creates directory
chdir: changes current directory
rmdir: removes directory
For renames directory no special
function, you must  write you own.
Alex

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
abdijCommented:
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
0
W122498Author Commented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.