[fpc-pascal] TMask and Case Sensitive matching
Bart
bartjunk64 at gmail.com
Wed Apr 28 13:32:44 CEST 2010
Hi, you all.
At current TMaks.Matches does a case insensitive matching of a
filename against a given mask(list).
Currently this comparison is case insensitive ('ABC.doc' matches the
mask 'abc*').
This is OK for Windows/DOS environments, but it will not do for case
sensitive operating systems (or filesystems) like Linux.
(This behaviour is probably due to Delphi compatibility?)
I would like to extent this so that matching can be done case
sensitive as well.
(Both Filename and Mask(list) will be treated case sensitive in that case).
For Delphi compatibility, this probably should not end up in TMask
itself, so I would suggest deriving TMask from TCustomMask, which will
have a protected property CaseSensitive, which will be False and not
be public for TMask.
(And make some overrides for MatchesMask and MatchesMaskList functions)
Something like:
TCustomMask = class
private
FMask: TMaskString;
FCaseSensitive: Boolean;
protected
property CaseSensitive: Boolean read FCaseSensitive write FCaseSensitive;
public
constructor Create(const AValue: String);
destructor Destroy; override;
function Matches(const AFileName: String): Boolean;
end;
TMask = class(TCustomMask);
end;
TExtMask = class(TMask)
public
property CaseSensitive;
end;
Any thoughts, ideas, objections (just shoot me) on that?
B.t.w. Shouldn't this functionality (Filename matching) be part of the
RTL instead of the LCL? (That's why I posted this also in fpc-pascal.)
AFAICR there is some extensive mask-matching algorithm in the linux
code for findfirst/findnext. If filename-matching code were to be part
of the RTL, then that would make code re-usable and easier to
maintain.
Bart
More information about the fpc-pascal
mailing list