FindFirst with faAnyFile doesn't return all files
Original Reporter info from Mantis: ggeldenhuys
-
Reporter name: Graeme Geldenhuys
Original Reporter info from Mantis: ggeldenhuys
- Reporter name: Graeme Geldenhuys
Description:
This was posted in the Lazarus mailing list a while back. The original author never reported this bug, so I am.
--------------- Copy ------------------------
I have had some headaches while using FindFirst function to search for
files in a folder.
I would share some gained knowledge with the people on this list.
Everybody knows about file attributes (archive, system, hidden, read only).
If someone use FindFirst('.', faAnyFile, SearchRec) it assumes that
faAnyFile is enough to get every file from the directory.
No, it is not. If a file has none of the attributes set, the faAnyFile
will not include that file in the search.
Those files, without any of the mentioned attributes set, they have
attribute Normal, and this attribute is not defined as faNormal anywhere
in RTL ( see
http://www.freepascal.org/docs-html/rtl/dos/fileattributes.html ).
If one would like to get all the files from a folder by using FindFirst
and FindNext, then he should use:
FindFirst('.', faAnyFile or $00000080, SearchRec);
--------------- END ------------------------
Apparently the same thing occurs in Delphi, but I also believe this is
a bug and should be solved in FPC.
I'm not sure if this relates to unix OS's, but it does for Windows.
Mantis conversion info:
- Mantis ID: 9440
- OS: Windows
- OS Build: win2000
- Build: r8256
- Platform: i386
- Version: 2.2.0
- Monitored by: » luizamerico (Luiz Americo), » @flyingsheep (Bart Broersma)