IonicWind Software

Aurora Compiler => General Discussion => Topic started by: Bruce Peaslee on October 02, 2006, 04:49:24 PM

Title: OpenFile() bug?
Post by: Bruce Peaslee on October 02, 2006, 04:49:24 PM
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()?
Title: Re: OpenFile() bug?
Post by: LarryMc on October 02, 2006, 04:53:27 PM
is f declared as an unsigned int?
Title: Re: OpenFile() bug?
Post by: Bruce Peaslee on October 02, 2006, 05:00:49 PM
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)
Title: Re: OpenFile() bug?
Post by: ExMember001 on October 02, 2006, 05:46:11 PM
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
Title: Re: OpenFile() bug?
Post by: Parker on October 02, 2006, 06:34:39 PM
I use that to check existance of files too :-\

However, the other check I use is
if( getfilelength( f ) > 0 )
{
    /* read... */
}
else
{
    /* error */
}
Title: Re: OpenFile() bug?
Post by: Ionic Wind Support Team 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.

Title: Re: OpenFile() bug?
Post by: Bruce Peaslee on October 02, 2006, 09:29:43 PM
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?
Title: Re: OpenFile() bug?
Post by: Ionic Wind Support Team on October 03, 2006, 12:03:44 AM
Windows API function GetLastError should do it.
Title: Re: OpenFile() bug?
Post by: Ionic Wind Support Team on October 03, 2006, 01:16:45 AM
I am changing the OpenFile function to return 0 on error.  Which is more consistant with other library functions.