View Issue Details

IDProjectCategoryView StatusLast Update
0024771LazarusLazUtilspublic2013-08-06 10:26
Reporterpoiuyt555 Assigned ToBart Broersma  
Status closedResolutionfixed 
Product Version1.0.8 
Fixed in Version1.1 (SVN) 
Summary0024771: FindAllFiles fails to find my file: c:\1\28 may
I have the file:
28 may
in directory
FindAllFiles falid to find my file: c:\1\28 may
Steps To ReproduceThis code didn't find this file (shows 0):
var tr:TStringList;
   tr := TStringList.Create;
   tr := findAllFiles('c:\1','28 may');

Can you fix it?
TagsNo tags attached.
Fixed in Revisionr42268
Attached Files


related to 0024821 closedBart Broersma No documentation for FindAllFiles file selection mask format 


Mattias Gaertner

2013-07-21 15:00

manager   ~0068986

FindAllFiles only finds files (not directories) and if you don't use * or ? in the mask then file file has to match exactly.
Is "28 may" a file and has it no extension?


2013-07-21 16:13

reporter   ~0068988

Yes, "28 may" is a file and has no extension.

Bart Broersma

2013-07-22 23:08

developer   ~0069004

The problem here is that TFileSearcher.Search internally uses a MaskList.
This is a list of Masks that is separated by a semicolon (by default), but it also splits a masklist value if it has a space character in it.
So your mask of "28 may" gets treated as two seprate masks: "28" and "may" (without the quotes of course).
This is a drawback of using MaskLists and it cannot befixed without breaking backwards compatibility.
I also do not know if not splitting a masklist with a space in it would be Delphi compatible.


2013-07-23 04:55

reporter   ~0069014

But i think it must be fixed. Because the result is wrong.
But, i don't know how to fix it. Maybe you sugest some working code to fix TMaskList.Matches function?
Or you may add some new functionality, like TWindowsMask?


2013-07-23 06:30

reporter   ~0069017

Last edited: 2013-07-23 06:44

View 3 revisions

And also i think it wrong because:
If a have a file:
one two three four.doc
And i definitely know that file name contains 'two three'.
I try to search like this:
tr := findAllFiles('c:\','*two three*');
And because of this bug - my search will fails.
And i must know that i have to search separately only
tr := findAllFiles('c:\','*two*');
tr := findAllFiles('c:\','*three*');

And if there are many files with 'two' or 'three' words within the name - it would be hard to find the needed file...!

And i think the most correct way in case of such search:
tr := findAllFiles('c:\','*two three*');
Search for '*two*' and '*three*' both.

Reinier Olislagers

2013-07-23 08:00

developer   ~0069018

Regardless of whether the filemask code is changed, IMO the expected behaviour should be documented.

There's a wiki page at
... don't know if the LCL xml/CHM help already contains an entry on FindAllFiles

Bart Broersma

2013-07-23 08:35

developer   ~0069019

You might want to try using sets [] in your mask if you want it to contain a space character.

If the behaviour of TMaskList (Splitting masks with a space) is Delphi compatible, it cannot be changed.
We could consider making this configurable (yet another parameter to TMaskList.Create and all functions that use it internally).

Mattias Gaertner

2013-07-23 09:16

manager   ~0069023

AFAIK FindAllFiles does not exist in Delphi. It is a LCL invention.
For consistency with the other file functions the separator should be a semicolon or given as parameter.


2013-07-23 10:07

reporter   ~0069024

I thought a little, and i think that this is not good variant:
> Search for '*two*' and '*three*' both.

The better way is to search
tr := findAllFiles('c:\','*two three*');
exactly '*two three*'
I.e. not consider spaces as a delimiter, but read them like any other letters.
I.e. use only this special symbols: * and ? plus the separator which should be given as the parameter

Bart Broersma

2013-07-23 10:55

developer   ~0069029

@poiuyt555: you keep repeating yourself.
It is obvious what you want. No need to repeat that.
It is not so obvious wether we can implement this, and how.
Please give us some time.

@Mattias: the real question is wether the behaviour of TMaskList (splitting values that contain a space character) is Delphi compatible.

Mattias Gaertner

2013-07-23 11:13

manager   ~0069030

AFAIK Delphi does not have TMaskList. It is a LCL feature.

Bart Broersma

2013-07-27 23:12

developer   ~0069127

@poiuyt555: for the time being (waiting discussion with Lazarus devels) you can use the following solution:

constructor TMaskList.Create(const AValue: String; ASeparator: Char; const CaseSensitive: Boolean);

Change the line:

  S := TParseStringList.Create(AValue, ASeparator + ' ');


  S := TParseStringList.Create(AValue, ASeparator); //remove adding the space

Then rebuild your program (Lazarus will rebuild the LCL for you).

FindAllFiles('c:\1','28 may') should now work.

As a side note: using FindAllFiles in the way you do (fixed mask, no wildcards) is a bit of overkill IMHO.


2013-07-29 15:16

reporter   ~0069143

Hi, Bart Broersma.
But your solution
Change the line:
  S := TParseStringList.Create(AValue, ASeparator + ' ');
  S := TParseStringList.Create(AValue, ASeparator); //remove adding the space

is not working:
I have file my.docx in 1.
FindAllFiles('c:\1','*.doc; *.docx;') - not working, result = 0.
FindAllFiles('c:\1','*.docx; *.doc;') - working.
Try it.

Mattias Gaertner

2013-07-29 15:22

manager   ~0069144

It seems you have a space in ' *.docx'.




2013-07-29 18:52

reporter   ~0069146

Thanks, Mattias, Bart.
Yes, you are right. I have i space.
But i've got used for such style: *.doc; *.docx; - with spaces, because it's simply to read such search string.
And i don't know how to deal with it - better reading from one side and search for files with spaces - from other.
Maybe use in TMaskList ASeparator: Char = '; ' - with space??

Bart Broersma

2013-07-29 21:55

developer   ~0069148

Last edited: 2013-07-29 21:56

View 2 revisions

You want to have it both ways. It should break on space and it should not, depending on how you intended it???
ASeparator could be a string in TMaskList's construcor allowing both, but it feels awkward to do that.


2013-07-30 04:58

reporter   ~0069149

Ok, thanks.
Now i think the better way - not to use space.
And use '*.doc;*.docx;' without spaces.

Bart Broersma

2013-08-02 22:45

developer   ~0069228

Please test and close if OK.


2013-08-06 10:26

reporter   ~0069274

Thanks, now it works correct.

Issue History

Date Modified Username Field Change
2013-07-21 14:36 poiuyt555 New Issue
2013-07-21 15:00 Mattias Gaertner Note Added: 0068986
2013-07-21 16:13 poiuyt555 Note Added: 0068988
2013-07-22 15:42 Bart Broersma Assigned To => Bart Broersma
2013-07-22 15:42 Bart Broersma Status new => assigned
2013-07-22 23:08 Bart Broersma Note Added: 0069004
2013-07-23 04:55 poiuyt555 Note Added: 0069014
2013-07-23 06:30 poiuyt555 Note Added: 0069017
2013-07-23 06:34 poiuyt555 Note Edited: 0069017 View Revisions
2013-07-23 06:44 poiuyt555 Note Edited: 0069017 View Revisions
2013-07-23 08:00 Reinier Olislagers Note Added: 0069018
2013-07-23 08:35 Bart Broersma Note Added: 0069019
2013-07-23 09:16 Mattias Gaertner Note Added: 0069023
2013-07-23 10:07 poiuyt555 Note Added: 0069024
2013-07-23 10:55 Bart Broersma Note Added: 0069029
2013-07-23 11:13 Mattias Gaertner Note Added: 0069030
2013-07-27 23:12 Bart Broersma Note Added: 0069127
2013-07-27 23:15 Bart Broersma LazTarget => -
2013-07-27 23:15 Bart Broersma Summary FindAllFiles falid to find my file: c:\1\28 may => FindAllFiles fails to find my file: c:\1\28 may
2013-07-29 15:16 poiuyt555 Note Added: 0069143
2013-07-29 15:22 Mattias Gaertner Note Added: 0069144
2013-07-29 18:52 poiuyt555 Note Added: 0069146
2013-07-29 21:55 Bart Broersma Note Added: 0069148
2013-07-29 21:56 Bart Broersma Note Edited: 0069148 View Revisions
2013-07-30 04:58 poiuyt555 Note Added: 0069149
2013-08-02 22:45 Bart Broersma Fixed in Revision => r42268
2013-08-02 22:45 Bart Broersma Note Added: 0069228
2013-08-02 22:45 Bart Broersma Status assigned => resolved
2013-08-02 22:45 Bart Broersma Fixed in Version => 1.1 (SVN)
2013-08-02 22:45 Bart Broersma Resolution open => fixed
2013-08-03 13:57 Reinier Olislagers Relationship added related to 0024821
2013-08-06 10:26 poiuyt555 Note Added: 0069274
2013-08-06 10:26 poiuyt555 Status resolved => closed