creating a directory..?

I need to :
1. Test to see if a directory exists.
2. If the directory does NOT exist, create it.

I can do this in PERL easy!, but how to do it in C++ ???

Any help would be appreciated.
Thanx
Playing with directories and files is an OS-specific thing.

However, the Boost Filesystem library is very nice.
http://www.boost.org/libs/filesystem/doc/index.htm

If you don't want to use Boost:

On Windows, check out MSDN. (Google msdn "directory management functions").

For unix and linux, check out the following:
http://linux.die.net/man/3/stat
http://linux.die.net/man/3/mkdir

Hope this helps.
Last edited on
thanks Duoas -

coming from Perl this is one of the more difficult transitions... in Perl I'd just :

if (-d "directoryname") { ... }

a piece of cake.

Thanks for the reply.

Ken
True, but underneath the sweet metallic veneer are all the gears and grease that deals with the OS...

Life in the turing microcosm goes like this:
Machine Language
Assembly Language
OS services
High-level languages (like C, Pascal, etc.)
Script languages (like Perl and Tcl)
GUI interfaces (j/k! ;-)

The closer you get to the machine, the more wizardly you become. Enjoy the ride!
Topic archived. No new replies allowed.