Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

CProgrammer

file_exists(php) for c++?

This topic is 5441 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

Advertisement
Not in the standard library.
Look into the boost filesystem library (www.boost.org). It is free and works on a few different platforms. If you only need this to work on one platform use that platform''s methods (win32 api or posix standard).

Share this post


Link to post
Share on other sites
quote:
Original post by CProgrammer
Is there an equivalent function to file_exists(php) for c++.

-CProgrammer


fopen can be used to see if a file exists (try to open it read only)

Share this post


Link to post
Share on other sites
quote:
Original post by George2
quote:
Original post by CProgrammer
Is there an equivalent function to file_exists(php) for c++.

-CProgrammer


fopen can be used to see if a file exists (try to open it read only)


Yeah that would work, but I''m using STL(std::ifstream) and it''d be a bit weird to open with fopen then close and open again.
-CProgrammer

Share this post


Link to post
Share on other sites
Your using std::ifstream aye?

just call open on your ifstream making sure you only have input caps on (ifstream will default to read only which will work i believe), and then check the open and good flags using is_open() and good() respectively.

i think that''ll work anyway

Lorenz (krysole) Pretterhofer
sleep, caffeine for the weak minded

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!