IDE: fixed CopySecondaryConfigFile to not create double path delims

git-svn-id: trunk@35118 -
This commit is contained in:
mattias 2012-02-04 09:14:13 +00:00
parent f85f1fd695
commit 353a841ec1
3 changed files with 31 additions and 23 deletions

View File

@ -46,7 +46,7 @@ interface
uses
Classes, SysUtils, LCLProc, FileUtil, Forms, Controls, Graphics, Dialogs,
LazHelpIntf, HelpIntfs, ComCtrls, StdCtrls, IDEHelpIntf, IDEDialogs,
IDEOptionsIntf;
IDEOptionsIntf, BaseIDEIntf;
const
MyHelpOptionID: integer = 10000; // an arbitrary number, choose a big number
@ -185,10 +185,23 @@ type
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
end;
procedure LoadMyIDEOptions(Filename: string);
procedure SaveMyIDEOptions(Filename: string);
procedure Register;
implementation
procedure LoadMyIDEOptions(Filename: string);
begin
end;
procedure SaveMyIDEOptions(Filename: string);
begin
end;
procedure Register;
begin
// register help databases

View File

@ -208,12 +208,19 @@ function GetLazIDEConfigStorage(const Filename: string; LoadFromDisk: Boolean
var
ConfigFilename: String;
begin
if LoadFromDisk then begin
if CompareFilenames(ExtractFilePath(Filename),GetPrimaryConfigPath)=0 then
ConfigFilename:=ExtractFileName(Filename)
else
ConfigFilename:=Filename;
if LoadFromDisk and (ExtractFilePath(ConfigFilename)='')
then begin
// copy template config file to users config directory
CopySecondaryConfigFile(Filename);
CopySecondaryConfigFile(ConfigFilename);
end;
// create storage
ConfigFilename:=AppendPathDelim(GetPrimaryConfigPath)+Filename;
if not FilenameIsAbsolute(ConfigFilename) then
ConfigFilename:=AppendPathDelim(GetPrimaryConfigPath)+ConfigFilename;
Result:=TXMLOptionsStorage.Create(ConfigFilename,LoadFromDisk);
end;

View File

@ -80,7 +80,7 @@ function GetSecondaryConfigPath: String;
procedure CreatePrimaryConfigPath;
procedure SetPrimaryConfigPath(const NewValue: String);
procedure SetSecondaryConfigPath(const NewValue: String);
procedure CopySecondaryConfigFile(const AFilename: String);
procedure CopySecondaryConfigFile(const ShortFilename: String);
function GetProjectSessionsConfigPath: String;
function GetDefaultTestBuildDirectory: string;
@ -279,29 +279,17 @@ end;
{---------------------------------------------------------------------------
CopySecondaryConfigFile procedure
---------------------------------------------------------------------------}
procedure CopySecondaryConfigFile(const AFilename: String);
procedure CopySecondaryConfigFile(const ShortFilename: String);
var
PrimaryFilename, SecondaryFilename: string;
SrcFS, DestFS: TFileStream;
begin
PrimaryFilename:=GetPrimaryConfigPath+PathDelim+AFilename;
SecondaryFilename:=GetSecondaryConfigPath+PathDelim+AFilename;
if ShortFilename='' then exit;
PrimaryFilename:=AppendPathDelim(GetPrimaryConfigPath)+ShortFilename;
SecondaryFilename:=AppendPathDelim(GetSecondaryConfigPath)+ShortFilename;
if (not FileExistsUTF8(PrimaryFilename))
and (FileExistsUTF8(SecondaryFilename)) then begin
try
SrcFS:=TFileStream.Create(UTF8ToSys(SecondaryFilename),fmOpenRead);
try
DestFS:=TFileStream.Create(UTF8ToSys(PrimaryFilename),fmCreate);
try
DestFS.CopyFrom(SrcFS,SrcFS.Size);
finally
DestFS.Free;
end;
finally
SrcFS.Free;
end;
except
end;
if not CopyFile(SecondaryFilename,PrimaryFilename) then
debugln(['WARNING: unable to copy config "',SecondaryFilename,'" to "',SecondaryFilename,'"']);
end;
end;