mirror of https://gitlab.com/basile.b/dexed.git
implemented new data location on linux, close #31
This commit is contained in:
parent
a57a0a69fa
commit
379d161a7b
|
@ -87,13 +87,13 @@ static this()
|
||||||
if (asSu)
|
if (asSu)
|
||||||
{
|
{
|
||||||
exePath = "/usr/bin";
|
exePath = "/usr/bin";
|
||||||
appDataPath = "/home/" ~ environment.get("SUDO_USER") ~ "/Coedit/";
|
appDataPath = "/home/" ~ environment.get("SUDO_USER") ~ "/.config/Coedit/";
|
||||||
shortCutPath = "/usr/share/applications/";
|
shortCutPath = "/usr/share/applications/";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
exePath = "/home/" ~ environment.get("USER") ~ "/bin/";
|
exePath = "/home/" ~ environment.get("USER") ~ "/bin/";
|
||||||
appDataPath = "/home/" ~ environment.get("USER") ~ "/Coedit/";
|
appDataPath = "/home/" ~ environment.get("USER") ~ "/.config/Coedit/";
|
||||||
shortCutPath = "/home/" ~ environment.get("USER") ~ "/.local/share/applications/";
|
shortCutPath = "/home/" ~ environment.get("USER") ~ "/.local/share/applications/";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ uses
|
||||||
Windows, JwaTlHelp32,
|
Windows, JwaTlHelp32,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$IFDEF LINUX}
|
{$IFDEF LINUX}
|
||||||
ExtCtrls,
|
ExtCtrls, FileUtil,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
dialogs, forms, process, asyncprocess;
|
dialogs, forms, process, asyncprocess;
|
||||||
|
|
||||||
|
@ -236,6 +236,36 @@ type
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
{$IFDEF LINUX}
|
||||||
|
var
|
||||||
|
// flag that indicates that migration is to be done on first call to getCoeditData...
|
||||||
|
doneLinuxDataMigration: boolean = false;
|
||||||
|
|
||||||
|
procedure MigrateOldData;
|
||||||
|
var
|
||||||
|
oldLocation: string;
|
||||||
|
newLocation: string;
|
||||||
|
err: boolean;
|
||||||
|
begin
|
||||||
|
err := false;
|
||||||
|
doneLinuxDataMigration := true;
|
||||||
|
oldLocation := sysutils.GetEnvironmentVariable('HOME') +'/Coedit';
|
||||||
|
if not DirectoryExists(oldLocation) then exit;
|
||||||
|
newLocation := getUserDataPath + 'Coedit';
|
||||||
|
try
|
||||||
|
try
|
||||||
|
CopyDirTree(oldLocation, newLocation,
|
||||||
|
[cffOverwriteFile,cffCreateDestDirectory,cffPreserveTime]);
|
||||||
|
except
|
||||||
|
err := true;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
if not err then
|
||||||
|
FileUtil.DeleteDirectory(oldLocation, false);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
procedure TCEPersistentShortcut.assign(aValue: TPersistent);
|
procedure TCEPersistentShortcut.assign(aValue: TPersistent);
|
||||||
var
|
var
|
||||||
src: TCEPersistentShortcut;
|
src: TCEPersistentShortcut;
|
||||||
|
@ -521,7 +551,7 @@ begin
|
||||||
result := sysutils.GetEnvironmentVariable('APPDATA');
|
result := sysutils.GetEnvironmentVariable('APPDATA');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$IFDEF LINUX}
|
{$IFDEF LINUX}
|
||||||
result := sysutils.GetEnvironmentVariable('HOME');
|
result := sysutils.GetEnvironmentVariable('HOME') + '/.config';
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$IFDEF DARWIN}
|
{$IFDEF DARWIN}
|
||||||
result := sysutils.GetEnvironmentVariable('HOME') + '/Library';
|
result := sysutils.GetEnvironmentVariable('HOME') + '/Library';
|
||||||
|
@ -534,6 +564,10 @@ end;
|
||||||
|
|
||||||
function getCoeditDocPath: string;
|
function getCoeditDocPath: string;
|
||||||
begin
|
begin
|
||||||
|
{$IFDEF LINUX}
|
||||||
|
if not doneLinuxDataMigration then
|
||||||
|
MigrateOldData;
|
||||||
|
{$ENDIF}
|
||||||
result := getUserDataPath + 'Coedit' + directorySeparator;
|
result := getUserDataPath + 'Coedit' + directorySeparator;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue