IDE: saving package links in lazarus source directory relative

git-svn-id: trunk@21923 -
This commit is contained in:
mattias 2009-09-29 20:27:27 +00:00
parent 3a996a5dad
commit 4f168cab7d
2 changed files with 26 additions and 4 deletions

View File

@ -40,6 +40,9 @@ uses
Classes, SysUtils, AVL_Tree, Laz_XMLCfg, FileProcs,
LCLProc, FileUtil, IDEProcs, MacroIntf, EnvironmentOpts, PackageDefs, LazConf;
const
PkgLinksFileVersion = 2;
type
{ TPackageLink
@ -452,6 +455,7 @@ var
i: Integer;
NewPkgLink: TPackageLink;
ItemPath: String;
FileVersion: LongInt;
begin
if fUpdateLock>0 then begin
Include(FStates,plsUserLinksNeedUpdate);
@ -470,11 +474,13 @@ begin
FUserLinksSortID.FreeAndClear;
FUserLinksSortFile.Clear;
FileVersion:=PkgLinksFileVersion;
XMLConfig:=nil;
try
XMLConfig:=TXMLConfig.Create(ConfigFilename);
Path:='UserPkgLinks/';
FileVersion:=XMLConfig.GetValue(Path+'Version',0);
LinkCount:=XMLConfig.GetValue(Path+'Count',0);
for i:=1 to LinkCount do begin
ItemPath:=Path+'Item'+IntToStr(i)+'/';
@ -523,7 +529,7 @@ begin
end;
end;
RemoveOldUserLinks;
Modified:=false;
Modified:=FileVersion<>PkgLinksFileVersion;
end;
procedure TPackageLinks.UpdateAll;
@ -581,6 +587,8 @@ var
ANode: TAVLTreeNode;
ItemPath: String;
i: Integer;
LazSrcDir: String;
AFilename: String;
begin
ConfigFilename:=GetUserLinkFile;
@ -591,6 +599,8 @@ begin
exit;
//DebugLn(['TPackageLinks.SaveUserLinks saving ... ',ConfigFilename]);
LazSrcDir:=EnvironmentOptions.LazarusDirectory;
XMLConfig:=nil;
try
XMLConfig:=TXMLConfig.CreateClean(ConfigFilename);
@ -604,7 +614,15 @@ begin
CurPkgLink:=TPackageLink(ANode.Data);
XMLConfig.SetDeleteValue(ItemPath+'Name/Value',CurPkgLink.Name,'');
CurPkgLink.Version.SaveToXMLConfig(XMLConfig,ItemPath+'Version/');
XMLConfig.SetDeleteValue(ItemPath+'Filename/Value',CurPkgLink.Filename,'');
// save package files in lazarus directory relative
AFilename:=CurPkgLink.Filename;
if (LazSrcDir<>'') and FileIsInPath(AFilename,LazSrcDir) then begin
AFilename:=CreateRelativePath(AFilename,LazSrcDir);
//DebugLn(['TPackageLinks.SaveUserLinks ',AFilename]);
end;
XMLConfig.SetDeleteValue(ItemPath+'Filename/Value',AFilename,'');
XMLConfig.SetDeleteValue(ItemPath+'LastCheckValid/Value',
CurPkgLink.LastCheckValid,false);
if CurPkgLink.LastCheckValid then

View File

@ -56,8 +56,8 @@ uses
// package registration
LazarusPackageIntf,
// IDE
LazarusIDEStrConsts, IDEProcs, LazConf, TransferMacros, DialogProcs,
IDETranslations, CompilerOptions, PackageLinks, PackageDefs,
LazarusIDEStrConsts, EnvironmentOpts, IDEProcs, LazConf, TransferMacros,
DialogProcs, IDETranslations, CompilerOptions, PackageLinks, PackageDefs,
ComponentReg, RegisterFCL, RegisterLCL, RegisterSynEdit, RegisterIDEIntf;
type
@ -450,6 +450,10 @@ begin
BeginUpdate(false);
try
AFilename:=PkgLink.Filename;
if not FilenameIsAbsolute(AFilename) then begin
// a package in the lazarus sources
AFilename:=TrimFilename(EnvironmentOptions.LazarusDirectory+PathDelim+AFilename);
end;
if not FileExistsUTF8(AFilename) then begin
DebugLn('invalid Package Link: file "'+AFilename+'" does not exist.');
PkgLink.FileDateValid:=false;