View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0034607||Lazarus||FCL||public||2018-11-26 13:39||2018-12-02 12:01|
|Reporter||Miguel Oliveira||Assigned To||Bart Broersma|
|Product Version||Product Build|
|Target Version||2.2||Fixed in Version||2.2|
|Summary||0034607: FindAllFiles and TFileSearcher will not retrieve filenames if the target directory contains a semicolon ";" in the name|
|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.|
|Tags||No tags attached.|
|Fixed in Revision||59687|
Please move to Lazarus. FindAllFiles is part of Lazutils package.
The separator for directories to search is hardcoded as ';' in TFileSearcher.Search.
Miguel, maybe you mean semicolon instead of semi-column.
Using it as part of a directory name sounds like begging for trouble.
Yes, but it's not illegal.
You cannot create it form commandline though:
md a;b will create direcotries a and b
You can in Explorer however.
We should make the separator a property of TFileSearcher and expose this in FindAllFiles via a default property in one of the overloads.
@Juha: if you object to this idea then please let me know, otherwise I'll implement it when I have the time.
There is already a TFileSearcher.MaskSeparator. Can't it be reused for this purpose?
And as a side-note: Recently I noticed that TListDirectorySearcher and TListFileSearcher override the methods DoDirectoryFound and DoFileFound without calling "inherited". Therefore, the events OnDirectoryFound and OnFileFound are never called. Having these events as optional parameters in FindAllDirectories/FindAllFiles might be useful sometimes (e.g. in order to count the total size of all found files - this was a forum question).
> Can't it be reused for this purpose?
Well, at some point somebody will want a ':' as part of a mask and have it used as pathseparator...
> @Juha: if you object to this idea then please let me know,
Fixed in r59687.
Please test and close if OK.
@wp: regarding your sidenote in note 0112218: can you open a separate report or commit the changes yourself?
It's rather odd it does not call inherited, so maybe it's on purpose?
Should this be merged to fixes 2?
It changes the signature of FindAllFiles/FindAllDirectories.
||Fixed semi-column->semicolon in summary.|
You are right: I meant semicolon, not semi-column! Sorry.
The ';' is being generated automatically when a filename encryption method encrypts a filename or a directory name. The rules for chars to be allowed in filenames exclude several chars like <>:/\| etc, but ';' is not excluded.
I am not creating directories manually and I am not using command line.
||@Miguel: did you try the fix? Does it work. If so please close this issue.|
I did not try the fix because I had already developed an alternative class using FindFirst/FindNext having a better interface for me, because the request method returns a 2-dimensional array containing both directories and files and for each item not not only file name but also file size, filedate and other atributes. I will not be using FindAllFiles any soon.
Anyway I have reported the bug not for myself but for the sake of Lazarus/Free Pascal. I see that the status is already "closed".
Keep up the good work.
Current staus is no "closed" but "resolved", which means that the person to whom this report is assigned (me) thinks he has fixed the issue.
It is customary for the person who opened the bugreport to close the report (there is a close button beneath the bug description), signaling to the the developer (me) that the fix works for you.
This is common practice in the use of the bugtracker.
|2018-11-26 13:39||Miguel Oliveira||New Issue|
|2018-11-26 13:59||Bart Broersma||Note Added: 0112204|
|2018-11-26 14:06||Bart Broersma||Note Edited: 0112204||View Revisions|
|2018-11-26 14:19||Michael Van Canneyt||Project||FPC => Lazarus|
|2018-11-26 15:37||Juha Manninen||Note Added: 0112208|
|2018-11-26 15:38||Juha Manninen||Note Edited: 0112208||View Revisions|
|2018-11-26 22:10||Bart Broersma||Note Added: 0112217|
|2018-11-26 22:10||Bart Broersma||Assigned To||=> Bart Broersma|
|2018-11-26 22:10||Bart Broersma||Status||new => assigned|
|2018-11-26 22:11||Bart Broersma||Note Edited: 0112217||View Revisions|
|2018-11-26 22:34||wp||Note Added: 0112218|
|2018-11-26 22:55||Bart Broersma||Note Added: 0112219|
|2018-11-27 17:32||Juha Manninen||Note Added: 0112234|
|2018-11-28 18:28||Bart Broersma||Fixed in Revision||=> 59687|
|2018-11-28 18:28||Bart Broersma||LazTarget||=> 2.2|
|2018-11-28 18:28||Bart Broersma||Note Added: 0112247|
|2018-11-28 18:28||Bart Broersma||Status||assigned => resolved|
|2018-11-28 18:28||Bart Broersma||Fixed in Version||=> 2.2|
|2018-11-28 18:28||Bart Broersma||Resolution||open => fixed|
|2018-11-28 18:28||Bart Broersma||Target Version||=> 2.2|
|2018-11-28 18:54||Bart Broersma||Note Added: 0112249|
|2018-11-28 18:54||Bart Broersma||Product Version||3.0.4 =>|
|2018-11-28 18:54||Bart Broersma||Summary||FindAllFiles and TFileSearcher will not retrieve filenames if the target directory contains a semi-column ";" in the name => FindAllFiles and TFileSearcher will not retrieve filenames if the target directory contains a semicolon ";" in the name|
|2018-11-29 16:29||Miguel Oliveira||Note Added: 0112261|
|2018-11-29 20:01||Bart Broersma||Note Added: 0112265|
|2018-12-01 13:04||Miguel Oliveira||Note Added: 0112290|
|2018-12-01 17:32||Bart Broersma||Note Added: 0112301|
|2018-12-02 12:01||Miguel Oliveira||Status||resolved => closed|