Archived

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

Crispy

checkinf if a file exists

Recommended Posts

hey what is the FASTEST way to check if a file exists. i''m fealing with a potentially large amount of files, so fopen(...)-ing and fclose(...)-ing each and every one of them on game startup would be a bit slow, wouldn''t it? thanks keep cool

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Try OpenFile() with the OF_EXIST style. That doesn''t actually open the file, just checks for existance. IME, it''s pretty fast.

Share this post


Link to post
Share on other sites
Windows : try GetFileAttributes()
*nix : stat() or fstat()

Alternatively, you can check the contents of directories against the list of your files

Windows : FindFirstFile() and FindNextFile()
*nix : opendir() and readdir()

Share this post


Link to post
Share on other sites