Checking if an Image Exists [cpp && d3d]

Started by
2 comments, last by Alan Kemp 19 years, 3 months ago
I need to check if a bitmap image specified by a filename exists or not before I try to use it. What function/technique can I use to find out? I'm using C++ and Direct3D.
.:<<-v0d[KA]->>:.
Advertisement
Assumming you dont want to use some 3rd party library like boost, how about:

#include <fstream>bool file_exists(const std::string & filename){    std::ifstream file(filename.c_str());    return file.is_open();}


Alan
"There will come a time when you believe everything is finished. That will be the beginning." -Louis L'Amour
Oh, didn't quite think of that. ifstream doesn't care if it's an image, does it?
.:<<-v0d[KA]->>:.
Its a generic Input File STREAM. It has absolutly no knowledge of whats in the file. Be aware that this will only tell you if the file exists or not, not if its a valid bitmap.

Alan
"There will come a time when you believe everything is finished. That will be the beginning." -Louis L'Amour

This topic is closed to new replies.

Advertisement