BOOL CheckFile(char* Filename)
{
FILE * stream;
stream = fopen(Filename, "rb" );
if(stream==NULL)
return FALSE;
fclose( stream );
return TRUE
}
Is there any better method ? faster, more reliable ?
any downside with the previous method ?
Thanks
Dan
Best code to check if a file is present
I don''t want to rely on return code of Dx8 loadtexture
for some reason and also while in debug mode it return some "file is missing" in the debug windows wich will let me miss some real file missing...
For now I use:
Your way works and is quite fast. The only better way I can think of off the top is if you are using C++ Builder. If so, just do this: "if (FileExists (FileName))". That will be slightly faster and is also slightly cleaner.
Your way works and is quite fast. The only better way I can think of off the top is if you are using C++ Builder. If so, just do this: "if (FileExists (FileName))". That will be slightly faster and is also slightly cleaner.
CheckFile() doesn''t work all the time. For example, a
file exists but you don''t have read permission.
Premature optimizations can only slow down your project even more.
What do you mean fast? You mean small amount of code right? I mean how much faster or slower can it be. You meant speed in regard to programming and not in regard to program execution right?
What do you mean fast? You mean small amount of code right? I mean how much faster or slower can it be. You meant speed in regard to programming and not in regard to program execution right?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement