forked from einsiedler90/Whonix-Starter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
whonixstarterappconfig.pas
72 lines (54 loc) · 1.63 KB
/
whonixstarterappconfig.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
(*
* Whonix Starter ( whonixstarterappconfig.pas )
*
* Copyright: 2012 - 2023 ENCRYPTED SUPPORT LP <[email protected]>
* Author: [email protected]
* License: See the file COPYING for copying conditions.
*)
unit WhonixStarterAppConfig;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils, FileUtil, WhonixUtils;
type
TAppConfig = record
VirtualBoxPath: string;
VBoxManagePath: string;
end;
procedure LoadWhonixStarterAppConfig;
procedure SaveWhonixStarterAppConfig;
var
AppConfig: TAppConfig;
implementation
uses IniFiles;
var
ini: TIniFile;
const
{$IFDEF WINDOWS}
defaultVirtualBoxPath = 'C:\Program Files\Oracle\VirtualBox\VirtualBox.exe';
defaultVBoxManagePath = 'C:\Program Files\Oracle\VirtualBox\VBoxManage.exe';
{$ELSE}
defaultVirtualBoxPath = '/usr/bin/VirtualBox';
defaultVBoxManagePath = '/usr/bin/VBoxManage';
{$ENDIF}
procedure LoadWhonixStarterAppConfig;
begin
AppConfig.VirtualBoxPath := ini.ReadString('AppConfig', 'VirtualBoxPath',
defaultVirtualBoxPath);
AppConfig.VBoxManagePath := ini.ReadString('AppConfig', 'VBoxManagePath',
defaultVBoxManagePath);
EnsureValidExePath(AppConfig.VirtualBoxPath, defaultVirtualBoxPath);
EnsureValidExePath(AppConfig.VBoxManagePath, defaultVBoxManagePath);
end;
procedure SaveWhonixStarterAppConfig;
begin
ini.WriteString('AppConfig', 'VirtualBoxPath', AppConfig.VirtualBoxPath);
ini.WriteString('AppConfig', 'VBoxManagePath', AppConfig.VBoxManagePath);
end;
initialization
ini := TIniFile.Create(GetAppConfigDir(False) + 'Whonix.ini');
LoadWhonixStarterAppConfig;
finalization
SaveWhonixStarterAppConfig;
ini.Free;
end.