mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-08 23:37:23 +01:00
parent
17e34abc62
commit
d9d1a7fa5d
@ -18,13 +18,21 @@ function ChangeFileExt(const FileName, Extension: PathStr): PathStr;
|
|||||||
var
|
var
|
||||||
i : longint;
|
i : longint;
|
||||||
EndSep : Set of Char;
|
EndSep : Set of Char;
|
||||||
|
SOF : Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
i := Length(FileName);
|
i := Length(FileName);
|
||||||
EndSep:=AllowDirectorySeparators+AllowDriveSeparators+[ExtensionSeparator];
|
EndSep:=AllowDirectorySeparators+AllowDriveSeparators+[ExtensionSeparator];
|
||||||
while (I > 0) and not(FileName[I] in EndSep) do
|
while (I > 0) and not(FileName[I] in EndSep) do
|
||||||
Dec(I);
|
Dec(I);
|
||||||
if (I = 0) or (FileName[I] <> ExtensionSeparator) then
|
if (I = 0) or (FileName[I] <> ExtensionSeparator) then
|
||||||
I := Length(FileName)+1;
|
I := Length(FileName)+1
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
SOF:=(I=1) or (FileName[i-1] in AllowDirectorySeparators);
|
||||||
|
if (SOF) and not FirstDotAtFileNameStartIsExtension then
|
||||||
|
I:=Length(FileName)+1;
|
||||||
|
end;
|
||||||
Result := Copy(FileName, 1, I - 1) + Extension;
|
Result := Copy(FileName, 1, I - 1) + Extension;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user