file_exists(php) for c++?

Started by
4 comments, last by CProgrammer 20 years, 2 months ago
Is there an equivalent function to file_exists(php) for c++. -CProgrammer
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).
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)
"THE INFORMATION CONTAINED IN THIS REPORT IS CLASSIFIED; DO NOT GO TO FOX NEWS TO READ OR OBTAIN A COPY." , the pentagon
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
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
Ah thanks
-CPogrammer

This topic is closed to new replies.

Advertisement