[fpc-devel] [Go32v2] LFN FindFirst bug

Jonas Maebe jonas.maebe at elis.ugent.be
Tue Feb 28 20:50:22 CET 2012

On 28 Feb 2012, at 20:50, Marco Borsari wrote:

> on system with long file name support activated (I have FreeDos with doslfn), the example below types all files instead of directory only.

That is by design, see http://www.freepascal.org/docs-html/rtl/sysutils/findfirst.html (the same goes for the findfirst from the Dos unit), in particular:

It is a common misconception that Attr specifies a set of attributes which must be matched in order for a file to be included in the list. This is not so: The value of Attr specifies additional attributes, this means that the returned files are either normal files or have an attribute which is present in Attr.

Specifically: specifying faDirectory as a value for Attr does not mean that only directories will be returned. Normal files and directories will be returned.

You have to check the attributes of the returned entries to see whether they match what you want. This is TP/Delphi-compatible.


More information about the fpc-devel mailing list