* Fix bug ID #18550

git-svn-id: trunk@27774 -
This commit is contained in:
michael 2014-05-11 17:14:20 +00:00
parent 17e34abc62
commit d9d1a7fa5d

View File

@ -18,13 +18,21 @@ function ChangeFileExt(const FileName, Extension: PathStr): PathStr;
var
i : longint;
EndSep : Set of Char;
SOF : Boolean;
begin
i := Length(FileName);
EndSep:=AllowDirectorySeparators+AllowDriveSeparators+[ExtensionSeparator];
while (I > 0) and not(FileName[I] in EndSep) do
Dec(I);
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;
end;