I experimented 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 returns false. For instance:
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 the file name. Therefore, if I want to exclude, for example, all files in c: [test] *, what can I do here? My only solution is to make a StringReplace if [found, but it will be slower 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?
source
share