mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: Setup %COMMANDER_INI% environment variable (some plugins use it to determine configuration directory)
This commit is contained in:
parent
6f2ce23ff5
commit
158bc5f7aa
1 changed files with 1 additions and 60 deletions
|
|
@ -1,60 +1 @@
|
|||
unit uGlobsPaths;
|
||||
|
||||
interface
|
||||
|
||||
var
|
||||
gpExePath : String = ''; // executable directory
|
||||
gpCfgDir : String = ''; // directory from which configuration files are used
|
||||
gpGlobalCfgDir : String = ''; // config dir global for all user
|
||||
gpCmdLineCfgDir : String = ''; // config dir passed on the command line
|
||||
gpLngDir : String = ''; // path to language *.po files
|
||||
gpPixmapPath : String = ''; // path to pixmaps
|
||||
gpCacheDir : UTF8String = ''; // cache directory
|
||||
|
||||
procedure LoadPaths;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
SysUtils, FileUtil, uDebug, uOSUtils, DCOSUtils, DCStrUtils;
|
||||
|
||||
function GetAppName : String;
|
||||
begin
|
||||
Result := 'doublecmd';
|
||||
end;
|
||||
|
||||
procedure LoadPaths;
|
||||
begin
|
||||
OnGetApplicationName := @GetAppName;
|
||||
gpExePath := ExtractFilePath(TryReadAllLinks(ParamStrUTF8(0)));
|
||||
DCDebug('Executable directory: ', gpExePath);
|
||||
|
||||
gpGlobalCfgDir := gpExePath;
|
||||
if gpCmdLineCfgDir <> EmptyStr then
|
||||
begin
|
||||
if GetPathType(gpCmdLineCfgDir) <> ptAbsolute then
|
||||
gpCmdLineCfgDir := IncludeTrailingPathDelimiter(mbGetCurrentDir) + gpCmdLineCfgDir;
|
||||
gpCmdLineCfgDir := ExpandAbsolutePath(gpCmdLineCfgDir);
|
||||
gpCfgDir := gpCmdLineCfgDir;
|
||||
end
|
||||
else
|
||||
begin
|
||||
gpCfgDir := GetAppConfigDir;
|
||||
if gpCfgDir = EmptyStr then
|
||||
begin
|
||||
DCDebug('Warning: Cannot get user config directory.');
|
||||
gpCfgDir := gpGlobalCfgDir;
|
||||
end;
|
||||
end;
|
||||
|
||||
gpCfgDir := IncludeTrailingPathDelimiter(gpCfgDir);
|
||||
gpLngDir := gpExePath + 'language' + DirectorySeparator;
|
||||
gpPixmapPath := gpExePath + 'pixmaps' + DirectorySeparator;
|
||||
gpCacheDir := GetAppCacheDir;
|
||||
|
||||
// set up environment variables
|
||||
mbSetEnvironmentVariable('COMMANDER_DRIVE', ExtractRootDir(gpExePath));
|
||||
mbSetEnvironmentVariable('COMMANDER_PATH', ExcludeTrailingBackslash(gpExePath));
|
||||
end;
|
||||
|
||||
end.
|
||||
unit uGlobsPaths;
interface
var
gpExePath : String = ''; // executable directory
gpCfgDir : String = ''; // directory from which configuration files are used
gpGlobalCfgDir : String = ''; // config dir global for all user
gpCmdLineCfgDir : String = ''; // config dir passed on the command line
gpLngDir : String = ''; // path to language *.po files
gpPixmapPath : String = ''; // path to pixmaps
gpCacheDir : UTF8String = ''; // cache directory
procedure LoadPaths;
implementation
uses
SysUtils, FileUtil, uDebug, uOSUtils, DCOSUtils, DCStrUtils;
function GetAppName : String;
begin
Result := 'doublecmd';
end;
procedure LoadPaths;
begin
OnGetApplicationName := @GetAppName;
gpExePath := ExtractFilePath(TryReadAllLinks(ParamStrUTF8(0)));
DCDebug('Executable directory: ', gpExePath);
gpGlobalCfgDir := gpExePath;
if gpCmdLineCfgDir <> EmptyStr then
begin
if GetPathType(gpCmdLineCfgDir) <> ptAbsolute then
gpCmdLineCfgDir := IncludeTrailingPathDelimiter(mbGetCurrentDir) + gpCmdLineCfgDir;
gpCmdLineCfgDir := ExpandAbsolutePath(gpCmdLineCfgDir);
gpCfgDir := gpCmdLineCfgDir;
end
else
begin
gpCfgDir := GetAppConfigDir;
if gpCfgDir = EmptyStr then
begin
DCDebug('Warning: Cannot get user config directory.');
gpCfgDir := gpGlobalCfgDir;
end;
end;
gpCfgDir := IncludeTrailingPathDelimiter(gpCfgDir);
gpLngDir := gpExePath + 'language' + DirectorySeparator;
gpPixmapPath := gpExePath + 'pixmaps' + DirectorySeparator;
gpCacheDir := GetAppCacheDir;
// set up environment variables
mbSetEnvironmentVariable('COMMANDER_INI', gpCfgDir + 'doublecmd.xml');
mbSetEnvironmentVariable('COMMANDER_DRIVE', ExtractRootDir(gpExePath));
mbSetEnvironmentVariable('COMMANDER_PATH', ExcludeTrailingBackslash(gpExePath));
end;
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue