LazUtils: Masks: on Windows 'foo.*' should also match 'foo' (depends on quirks used). Patch by Jose Mejuto. Issue #39462.

This commit is contained in:
Bart 2021-11-20 12:56:59 +01:00
parent 2e7022648b
commit 7c0fdd1281

View File

@ -1436,7 +1436,8 @@ begin
// Quirk "blah.*" = "blah*" // Quirk "blah.*" = "blah*"
if wqAnyExtension in fWindowsQuirkAllowed then begin if wqAnyExtension in fWindowsQuirkAllowed then begin
if RightStr(lModifiedMask,3)='*.*' then begin if (RightStr(lModifiedMask,2)='.*') and (Length(lModifiedMask)>2) then begin
//if RightStr(lModifiedMask,3)='*.*' then begin
lModifiedMask:=copy(lModifiedMask,1,Length(lModifiedMask)-2); lModifiedMask:=copy(lModifiedMask,1,Length(lModifiedMask)-2);
fWindowsQuirkInUse:=fWindowsQuirkInUse+[wqAnyExtension]; fWindowsQuirkInUse:=fWindowsQuirkInUse+[wqAnyExtension];
end; end;
@ -1499,7 +1500,15 @@ begin
if wqNoExtension in fWindowsQuirkInUse then begin if wqNoExtension in fWindowsQuirkInUse then begin
SplitFileNameExtension(aFileName,lFileName,lExtension,false); SplitFileNameExtension(aFileName,lFileName,lExtension,false);
// wqNoExtension = Empty extension // wqNoExtension = Empty extension
if lExtension<>'' then exit(false); //if lExtension<>'' then exit(false);
// Its not clear if a file "file." should match an "*." mask because
// there is no way in Windows that a file ends with a dot.
if (lExtension<>'') and (lExtension<>'.') then
exit(false)
end else if wqAnyExtension in fWindowsQuirkInUse then begin
SplitFileNameExtension(aFileName,lFileName,lExtension,false);
Result:=inherited Matches(lFileName);
exit;
end; end;
Result:=Inherited Matches(aFileName); Result:=Inherited Matches(aFileName);
end; end;