27.05.2010, 22:43
I was unsure about posting this in code snippets or here, but I think General Reference is more appropiate.
There is no native way to know if a File: tagged variable does currently hold an opened file or not. Even although it initialized at false, once fclose is called, it will stay true. This can be "fixed" by adding this simple snippet at the top of your code (before using fclose):
This way, you can now do stuff like:
There is no native way to know if a File: tagged variable does currently hold an opened file or not. Even although it initialized at false, once fclose is called, it will stay true. This can be "fixed" by adding this simple snippet at the top of your code (before using fclose):
pawn Код:
stock default_fclose(File:handler) return fclose(handler);
#define fclose(%1) default_fclose(%1); %1=File:false
pawn Код:
new File:handler;
if(handler)
print("File is opened!");
else
print("File is not opened");