I have been experimenting with TMask in Delphi 2010 and it seems to work as expected except in one situation: when the mask name contains [ or ] the mask always seem to return false. For example:
var
MaskObj : TMask;
begin
MaskObj:= TMask.Create('c:\[test]\*');
try
Result:= MaskObj.Matches('c:\[test]\text');
finally
FreeAndNil(MaskObj);
end;
end;
returns false. ...
Yes, [ and ] are legal characters in file name. So if I want to exclude for example all files in c:[test]*, what could I do here? My only solution is to do a StringReplace if [ is detected, but this will be slow for a large number of files:
if (pos('[', Mask)>0) then
begin
mask:= ReplaceString(Mask, '[','_', etc...
// and do the same for the file name---
end;
Is there any other approach?