This doesn't catch the fact that there is no file:
f = OpenFile(sFileName, MODE_READ);
ÂÃ, Ã‚Ã, if(f)
ÂÃ, Ã‚Ã, {
ÂÃ, Ã‚Ã, Ã‚Ã, proceed
ÂÃ, Ã‚Ã, }
ÂÃ, Ã‚Ã, else
ÂÃ, Ã‚Ã, {
ÂÃ, Ã‚Ã, Ã‚Ã, error message
ÂÃ, Ã‚Ã, }
Am I doing this right or is there a problem with OpenFile()?
is f declared as an unsigned int?
Quote from: Larry McCaughn on October 02, 2006, 04:53:27 PM
is f declared as an unsigned int?
No, but I changed it and it made no difference. (It is shown as unsigned int in fileio.inc)
just played a bit with openfile..
if you change:
if (f)
to:
if (f = 1)
it works.
but if i use :
if (f <> 0) of if (f)
it doesnt work
I use that to check existance of files too :-\
However, the other check I use is
if( getfilelength( f ) > 0 )
{
/* read... */
}
else
{
/* error */
}
No, just not documented well yet. OpenFile returns and invalid handle value on error. 0xFFFFFFFF or -1 int.
Quote from: Paul Turley on October 02, 2006, 06:48:29 PM
No, just not documented well yet.ÂÃ, OpenFile returns and invalid handle value on error.ÂÃ, 0xFFFFFFFF or -1 int.
This works. But is there some way to get the specific error?
Windows API function GetLastError should do it.
I am changing the OpenFile function to return 0 on error. Which is more consistant with other library functions.