FindAllFiles and TFileSearcher will not retrieve filenames if the target directory contains a semicolon ";" in the name
Original Reporter info from Mantis: migol
-
Reporter name: Miguel Oliveira
Original Reporter info from Mantis: migol
- Reporter name: Miguel Oliveira
Description:
The free pascal function "FindAllFiles()" and the class "TFileSearcher" are BUGGY in very unusual cases.
If a Directory name contains a semi-column ";" in the name (for example directory "abcde;efgh" then no file names will be retrieved
from that directory! This is because Lazarus/free pascal somewhere reserves the ';' semicolumn as a separator for the mask of filenames to retrieve.
For example '.pas;.inc;*.pdf' . Had free pascal used for example the pipe char '|' as a separator (a character that is not allowed by a OS in file or
directory names) this bug would not occur. But a semi-column is allowed in file and directory names thus the separator is interfering!
When using the class TFileSearcher, there is a property "MaskSeparator" that can be set, but setting it to '|' does not aliviate this bug,
as the contents of a directory containing a semi-column in the name still will not be retrieved.
I had to create my own substitute class for "TFileSearcher" (using FindFirst() and FindNext() in order to be able to retrieve the contents of directories containing a semi-column ';' in the directory name.
Steps to reproduce:
Just create a directory with a name like "c:\myspecial;Directory" containing more than one file inside and try to retrieve the names of those files using "FindAllFiles()" or "TFileSearcher". You will obtain a TStringList object without any file names in it.
Mantis conversion info:
- Mantis ID: 34607
- OS: Windows
- OS Build: 10
- Platform: Lazarus
- Fixed in version: 2.2
- Fixed in revision: 59687 (#34803af7)
- Monitored by: » @xhajt03 (Tomas Hajny), » @flyingsheep (Bart Broersma)
- Target version: 2.2