You are not logged in.
Pages: 1
Could a function like this be introduced:
function MakeFileName(const pmcPart: array of const; pmLastIsExt: Boolean): TFileName;
var
ext: RawUtf8;
begin
if pmLastIsExt
and (Length(pmcPart) > 1)
and VarRecToUtf8IsString(pmcPart[High(pmcPart)], ext) then
begin
Result := MakePath(Slice(pmcPart, Length(pmcPart) - 1));
if (Result <> '')
and (ext <> '') then
begin
if ext[1] = '.' then
Result := Result + Utf8ToString(ext)
else
Result := Result + '.' + Utf8ToString(ext);
end;
end
else
Result := MakePath(pmcPart);
end;
Then you could write the following without looking at anything:
const
PNG_EXT = 'png';
begin
ShowMessage(MakeFileName([Executable.ProgramFilePath, 'One', 'TestFile', PNG_EXT], True));
ShowMessage(MakeFileName(['C:', 'One', 'TestFile', ExtractFileExt(Executable.ProgramFileName)], True));
With best regards
Thomas
Offline
Offline
Pages: 1