[Lazarus] GetAllFilesMask / AllFilesMask
bartjunk64 at gmail.com
Wed May 1 14:45:59 CEST 2013
On 5/1/13, Jürgen Hestermann <juergen.hestermann at gmx.de> wrote:
> But wasn't the original problem that AllFilesMask was wrong on Windows?
Supplying either '*.*' or '*' to FindFirst() function on Windows will
correctly list all files.
The prblem was that the mask supplied to TMaskList.Matches() did not
give the expected results, because Matches() treats at the given mask
like Linux does (as apparently does Delphi).
> But this means that the underlying OS will never see the mask that the
> programmer has given.
You cannot call FindFirst() with a masklist ('*.jpg;*.bmp') so you
must either filter yourself or make repeated calls to FindFirst with
each and every mask of the makslist.
> > It can only be "really" fixed if we have a different Matches function.
> > But even then, the results may differ across Windows versions (as
> > explained earlier).
> I don't understand. Before you wrote that FP is using the AllFilesMask and
> then filters further internaly. Now you say that the outcome would be
> different on different OS's.
No, I did not say that.
Windows itself behaves different across versions, in the way it treats
borderline cases (like 'foo.'), when supplying it to the dir command
(or FindFirst function).
I implemented a new MatchesWindowsMask function in TMask that ATM
seems to mimic the behaviour of "Dir", and I made TFileSearcher use
that on if you are on Windows.
It now handles masks like 'foo*.*', 'foo.' and 'foo.*' etc. as exected.
(See r40970 and r40973)
This implementation of course does not depend on Windows version,
because we programmed it ourselves.
In future, however, it may differ form the way "Dir" treats wildcards,
since MS has not documented how borderline cases should be treated in
the frist place.
More information about the Lazarus