Jump to content
  • Advertisement
Sign in to follow this  
biohaz

how do you check if a directory exists and create it if it doesn't in c++?

This topic is 3790 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do you check if a directory exists and create it if it doesn't? For example, I am writing a screenshot function and I want to save it in a screenshots folder, but I am uncertian that it is there on execution, thus would like to create it so I can save my screenshot, otherwise it will not write it to a non existant directory. Thanks. *I am aiming for platform independance, so I hope it does not need the windows api EDIT: forgot to mention I am using C++ [Edited by - biohaz on February 5, 2008 12:37:12 AM]

Share this post


Link to post
Share on other sites
Advertisement
Which language are you using?

In C++ there is no built in way to do this. Have a look at the boost libraries though, as they provide a very good filesystem library.
Other languages may provide this feature as a built in, but we need more details to answer your question.

Share this post


Link to post
Share on other sites
oops, yea using c++. I thought it was not built in, otherwise I would have found it by now. I guess I will look for the boost library for it. Thanks

Share this post


Link to post
Share on other sites
Boost is very worthwhile. Highly recommended. It's (C++)++.

You might be able to get away with

system("mkdir foo");

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!