FIX: Range check error

(cherry picked from commit 4aaa48f26e)
This commit is contained in:
Alexander Koblov 2022-06-12 15:22:52 +03:00
commit 012607073e

View file

@ -835,20 +835,24 @@ end;
function ApplyRenameMask(aFileName: String; NameMask: String; ExtMask: String): String;
function ApplyMask(const TargetString: String; Mask: String): String;
function ApplyMask(const TargetString, Mask: String): String;
var
i:Integer;
I: Integer;
begin
Result:='';
for i:=1 to Length(Mask) do
begin
if Mask[i]= '?' then
Result:=Result + TargetString[i]
else
if Mask[i]= '*' then
Result:=Result + Copy(TargetString, i, Length(TargetString) - i + 1)
else
Result:=Result + Mask[i];
if (Length(TargetString) < Length(Mask)) then
Result:= TargetString
else begin
Result:= String.Empty;
for I:= 1 to Length(Mask) do
begin
if Mask[I] = '?' then
Result:=Result + TargetString[I]
else
if Mask[I] = '*' then
Result:= Result + Copy(TargetString, I, Length(TargetString) - I + 1)
else
Result:= Result + Mask[I];
end;
end;
end;