On Mon, 18 May 2009, Marco van de Voort wrote:

In our previous episode, Jonas Maebe said:

Yes.

Huh ? Since when is this requirement ?

Since as long as I can remember. It at least predates the switch to
svn (revision 1 of both rtl/unix/dos.pp and of rtl/unix/sysutils.pp
requires it).

The current situation is probably simply the old "linux" unit routines
folded into sysutils. The fact that it is documented that way probably makes
it more than likely it was no mistake.

Given that I documented it, I'd rather say that I was sloppy in the
formulation. I've always assumed that the findclose was only needed
in case of a _succesful_ findfirst, i.e. one that returns 0.
And I've seen a lot of code that assumes the same (admittedly, it was
Win32 code).

Once more, if this is so, there is a lot of code that needs to be
checked in FPC. It might be easier to "fix" findfirst so that in case
of an error (nonzero return value), the searchrec record is cleared,
and the findclose() call is redundant.

I checked the windows code, and FindClose explicitly checks that
the searchrec record contains a valid handle (i.e. NOT
INVALID_HANDLE_VALUE), so all platforms would behave the same.

Opinions ? If no-one objects, I'll implement the 'fix', it's only
2 lines of code.

Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to