mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-22 10:20:33 +01:00
IDE: fixed CopySecondaryConfigFile to not create double path delims
git-svn-id: trunk@35118 -
This commit is contained in:
parent
f85f1fd695
commit
353a841ec1
@ -46,7 +46,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, SysUtils, LCLProc, FileUtil, Forms, Controls, Graphics, Dialogs,
|
Classes, SysUtils, LCLProc, FileUtil, Forms, Controls, Graphics, Dialogs,
|
||||||
LazHelpIntf, HelpIntfs, ComCtrls, StdCtrls, IDEHelpIntf, IDEDialogs,
|
LazHelpIntf, HelpIntfs, ComCtrls, StdCtrls, IDEHelpIntf, IDEDialogs,
|
||||||
IDEOptionsIntf;
|
IDEOptionsIntf, BaseIDEIntf;
|
||||||
|
|
||||||
const
|
const
|
||||||
MyHelpOptionID: integer = 10000; // an arbitrary number, choose a big number
|
MyHelpOptionID: integer = 10000; // an arbitrary number, choose a big number
|
||||||
@ -185,10 +185,23 @@ type
|
|||||||
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
|
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure LoadMyIDEOptions(Filename: string);
|
||||||
|
procedure SaveMyIDEOptions(Filename: string);
|
||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
procedure LoadMyIDEOptions(Filename: string);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure SaveMyIDEOptions(Filename: string);
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
begin
|
begin
|
||||||
// register help databases
|
// register help databases
|
||||||
|
|||||||
@ -208,12 +208,19 @@ function GetLazIDEConfigStorage(const Filename: string; LoadFromDisk: Boolean
|
|||||||
var
|
var
|
||||||
ConfigFilename: String;
|
ConfigFilename: String;
|
||||||
begin
|
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
|
// copy template config file to users config directory
|
||||||
CopySecondaryConfigFile(Filename);
|
CopySecondaryConfigFile(ConfigFilename);
|
||||||
end;
|
end;
|
||||||
// create storage
|
// create storage
|
||||||
ConfigFilename:=AppendPathDelim(GetPrimaryConfigPath)+Filename;
|
if not FilenameIsAbsolute(ConfigFilename) then
|
||||||
|
ConfigFilename:=AppendPathDelim(GetPrimaryConfigPath)+ConfigFilename;
|
||||||
Result:=TXMLOptionsStorage.Create(ConfigFilename,LoadFromDisk);
|
Result:=TXMLOptionsStorage.Create(ConfigFilename,LoadFromDisk);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@ -80,7 +80,7 @@ function GetSecondaryConfigPath: String;
|
|||||||
procedure CreatePrimaryConfigPath;
|
procedure CreatePrimaryConfigPath;
|
||||||
procedure SetPrimaryConfigPath(const NewValue: String);
|
procedure SetPrimaryConfigPath(const NewValue: String);
|
||||||
procedure SetSecondaryConfigPath(const NewValue: String);
|
procedure SetSecondaryConfigPath(const NewValue: String);
|
||||||
procedure CopySecondaryConfigFile(const AFilename: String);
|
procedure CopySecondaryConfigFile(const ShortFilename: String);
|
||||||
function GetProjectSessionsConfigPath: String;
|
function GetProjectSessionsConfigPath: String;
|
||||||
|
|
||||||
function GetDefaultTestBuildDirectory: string;
|
function GetDefaultTestBuildDirectory: string;
|
||||||
@ -279,29 +279,17 @@ end;
|
|||||||
{---------------------------------------------------------------------------
|
{---------------------------------------------------------------------------
|
||||||
CopySecondaryConfigFile procedure
|
CopySecondaryConfigFile procedure
|
||||||
---------------------------------------------------------------------------}
|
---------------------------------------------------------------------------}
|
||||||
procedure CopySecondaryConfigFile(const AFilename: String);
|
procedure CopySecondaryConfigFile(const ShortFilename: String);
|
||||||
var
|
var
|
||||||
PrimaryFilename, SecondaryFilename: string;
|
PrimaryFilename, SecondaryFilename: string;
|
||||||
SrcFS, DestFS: TFileStream;
|
|
||||||
begin
|
begin
|
||||||
PrimaryFilename:=GetPrimaryConfigPath+PathDelim+AFilename;
|
if ShortFilename='' then exit;
|
||||||
SecondaryFilename:=GetSecondaryConfigPath+PathDelim+AFilename;
|
PrimaryFilename:=AppendPathDelim(GetPrimaryConfigPath)+ShortFilename;
|
||||||
|
SecondaryFilename:=AppendPathDelim(GetSecondaryConfigPath)+ShortFilename;
|
||||||
if (not FileExistsUTF8(PrimaryFilename))
|
if (not FileExistsUTF8(PrimaryFilename))
|
||||||
and (FileExistsUTF8(SecondaryFilename)) then begin
|
and (FileExistsUTF8(SecondaryFilename)) then begin
|
||||||
try
|
if not CopyFile(SecondaryFilename,PrimaryFilename) then
|
||||||
SrcFS:=TFileStream.Create(UTF8ToSys(SecondaryFilename),fmOpenRead);
|
debugln(['WARNING: unable to copy config "',SecondaryFilename,'" to "',SecondaryFilename,'"']);
|
||||||
try
|
|
||||||
DestFS:=TFileStream.Create(UTF8ToSys(PrimaryFilename),fmCreate);
|
|
||||||
try
|
|
||||||
DestFS.CopyFrom(SrcFS,SrcFS.Size);
|
|
||||||
finally
|
|
||||||
DestFS.Free;
|
|
||||||
end;
|
|
||||||
finally
|
|
||||||
SrcFS.Free;
|
|
||||||
end;
|
|
||||||
except
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user