mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-14 14:19:08 +02:00
IDE: simplify code for getting package version in compiler options import/export.
git-svn-id: trunk@45632 -
This commit is contained in:
parent
bbbdc686ac
commit
e87969d7a6
@ -112,21 +112,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ReadIntFromXMLConfig(const Filename, Path: string;
|
|
||||||
DefaultValue, ValueForReadError: integer): integer;
|
|
||||||
var
|
|
||||||
XMLConfig: TXMLConfig;
|
|
||||||
begin
|
|
||||||
Result:=ValueForReadError;
|
|
||||||
if FileExistsUTF8(Filename) then
|
|
||||||
try
|
|
||||||
XMLConfig:=TXMLConfig.Create(Filename);
|
|
||||||
Result:=XMLConfig.GetValue(Path,DefaultValue);
|
|
||||||
except
|
|
||||||
Result:=ValueForReadError;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function GetXMLPathForCompilerOptions(XMLConfig: TXMLConfig): string;
|
function GetXMLPathForCompilerOptions(XMLConfig: TXMLConfig): string;
|
||||||
const
|
const
|
||||||
OptPathSuffix = 'SearchPaths/CompilerPath/Value';
|
OptPathSuffix = 'SearchPaths/CompilerPath/Value';
|
||||||
@ -147,8 +132,13 @@ begin
|
|||||||
else begin
|
else begin
|
||||||
// default: depending on file type
|
// default: depending on file type
|
||||||
Result:=DefaultCompilerOptPath;
|
Result:=DefaultCompilerOptPath;
|
||||||
if CompareFileExt(XMLConfig.Filename,'.lpk',false)=0 then begin
|
if CompareFileExt(XMLConfig.Filename,'.lpk',false)=0 then
|
||||||
FileVersion:=ReadIntFromXMLConfig(XMLConfig.Filename,PkgVersionPath,0,2);
|
begin
|
||||||
|
try
|
||||||
|
FileVersion:=XMLConfig.GetValue(PkgVersionPath,0);
|
||||||
|
except
|
||||||
|
FileVersion:=2; // On error assume version 2.
|
||||||
|
end;
|
||||||
if FileVersion>=2 then
|
if FileVersion>=2 then
|
||||||
Result:=PkgCompilerOptPath; // current lpk file
|
Result:=PkgCompilerOptPath; // current lpk file
|
||||||
end;
|
end;
|
||||||
@ -186,7 +176,7 @@ var
|
|||||||
begin
|
begin
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
try
|
try
|
||||||
InvalidateFileStateCache;
|
InvalidateFileStateCache(Filename);
|
||||||
XMLConfig:=TXMLConfig.Create(Filename);
|
XMLConfig:=TXMLConfig.Create(Filename);
|
||||||
try
|
try
|
||||||
Path:=DefaultCompilerOptPath;
|
Path:=DefaultCompilerOptPath;
|
||||||
|
Loading…
Reference in New Issue
Block a user