Skip to content

Commit 8a6d432

Browse files
committed
refactoring: some changes in path management
1 parent cbd7f76 commit 8a6d432

File tree

4 files changed

+31
-23
lines changed

4 files changed

+31
-23
lines changed

Forms/Forms.About.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ procedure TfrmAbout.imgDonateClick(Sender: TObject);
7676

7777
procedure TfrmAbout.imgLicenseClick(Sender: TObject);
7878
begin
79-
OpenDocument(AppendPathDelim(ASuiteInstance.Paths.SuitePathWorking) + 'docs' + PathDelim + 'license.txt');
79+
OpenDocument(AppendPathDelim(ASuiteInstance.Paths.SuitePathDocs) + 'license.txt');
8080
end;
8181

8282
procedure TfrmAbout.lnklblWebSiteClick(Sender: TObject);

Frame/Frame.Properties.General.Software.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function TfrmSWGeneralPropertyPage.InternalLoadData: Boolean;
106106
//lbInfo2.Caption := Format(lbInfo2.Caption, [ASuiteInstance.Paths.SuitePathWorking, ASuiteInstance.Paths.SuiteDrive]);
107107

108108
//Strange bug. %asuite% and %drive% causing error "Invalid argument index in format...", so I'm using a workaround
109-
lbInfo2.Caption := StringReplace(lbInfo2.Caption, '%s', ASuiteInstance.Paths.SuitePathWorking, [rfIgnoreCase]);
109+
lbInfo2.Caption := StringReplace(lbInfo2.Caption, '%s', ASuiteInstance.Paths.SuitePathASuiteFolder, [rfIgnoreCase]);
110110
lbInfo2.Caption := StringReplace(lbInfo2.Caption, '%s', ASuiteInstance.Paths.SuiteDrive, [rfIgnoreCase]);
111111

112112
if Assigned(CurrentNodeData) then

Library/AppConfig.Paths.pas

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,19 @@ interface
3333
TConfigPaths = class
3434
private
3535
FSuitePathCurrentTheme: String;
36-
FSuitePathList : String;
37-
FSuiteDrive : String;
38-
FSuitePathData : String;
39-
FSuitePathSettings: String;
40-
FSuitePathWorking : String;
36+
FSuitePathASuiteFolder: String;
37+
FSuitePathList : String;
38+
FSuiteDrive : String;
39+
FSuitePathData : String;
40+
FSuitePathSettings : String;
4141

4242
FEnvironmentVars : TPathList;
4343
FASuiteVars : TPathList;
4444

4545
function DeQuotedStr(AVar: AnsiString): AnsiString;
4646
function GetSuitePathBackup: String;
4747
function GetSuitePathCache: String;
48+
function GetSuitePathDocs: String;
4849
function GetSuitePathLocale: String;
4950
function GetSuitePathMenuThemes: String;
5051
procedure SetSuitePathCurrentTheme(AValue: String);
@@ -63,15 +64,16 @@ TConfigPaths = class
6364
procedure RemoveCacheFolders;
6465
procedure UpdatePathVariables;
6566

66-
property SuitePathList: String read FSuitePathList write FSuitePathList;
67-
property SuitePathSettings: String read FSuitePathSettings write FSuitePathSettings;
68-
property SuiteDrive: String read FSuiteDrive write FSuiteDrive;
69-
property SuitePathData: String read FSuitePathData write FSuitePathData;
70-
property SuitePathWorking: String read FSuitePathWorking write FSuitePathWorking;
67+
property SuitePathList: String read FSuitePathList write FSuitePathList; //Path to list
68+
property SuitePathSettings: String read FSuitePathSettings; //Path to settings
69+
property SuiteDrive: String read FSuiteDrive;
70+
property SuitePathData: String read FSuitePathData; //Path to folder data
71+
property SuitePathASuiteFolder: String read FSuitePathASuiteFolder; //Path to asuite.exe
7172
property SuitePathLocale: String read GetSuitePathLocale;
7273
property SuitePathCache: String read GetSuitePathCache;
7374
property SuitePathBackup: String read GetSuitePathBackup;
7475
property SuitePathMenuThemes: String read GetSuitePathMenuThemes;
76+
property SuitePathDocs: String read GetSuitePathDocs;
7577
property SuitePathCurrentTheme: String read FSuitePathCurrentTheme write SetSuitePathCurrentTheme;
7678

7779
property EnvironmentVars: TPathList read FEnvironmentVars;
@@ -164,14 +166,19 @@ function TConfigPaths.GetSuitePathCache: String;
164166
Result := AppendPathDelim(FSuitePathData + CACHE_DIR);
165167
end;
166168

169+
function TConfigPaths.GetSuitePathDocs: String;
170+
begin
171+
Result := AppendPathDelim(FSuitePathASuiteFolder + DOCS_DIR);
172+
end;
173+
167174
function TConfigPaths.GetSuitePathLocale: String;
168175
begin
169-
Result := AppendPathDelim(FSuitePathWorking + LOCALE_DIR);
176+
Result := AppendPathDelim(FSuitePathASuiteFolder + LOCALE_DIR);
170177
end;
171178

172179
function TConfigPaths.GetSuitePathMenuThemes: String;
173180
begin
174-
Result := AppendPathDelim(FSuitePathWorking + MENUTHEMES_DIR);
181+
Result := AppendPathDelim(FSuitePathASuiteFolder + MENUTHEMES_DIR);
175182
end;
176183

177184
procedure TConfigPaths.UpdateASuiteVars;
@@ -183,7 +190,7 @@ procedure TConfigPaths.UpdateASuiteVars;
183190
strFolderIcon := AppendPathDelim(FSuitePathCurrentTheme + ICONS_DIR);
184191

185192
//CONST_PATH_ASuite = Launcher's path
186-
FASuiteVars.Add(DeQuotedStr(CONST_PATH_ASUITE), ExcludeTrailingPathDelimiter(SuitePathWorking));
193+
FASuiteVars.Add(DeQuotedStr(CONST_PATH_ASUITE), ExcludeTrailingPathDelimiter(FSuitePathASuiteFolder));
187194

188195
//CONST_PATH_DRIVE = Launcher's Drive (ex. ASuite in H:\Software\ASuite.exe, CONST_PATH_DRIVE is H: )
189196
FASuiteVars.Add(DeQuotedStr(CONST_PATH_DRIVE), SUITEDRIVE);
@@ -201,7 +208,7 @@ constructor TConfigPaths.Create(APathExecutable: string);
201208
begin
202209
//Default paths
203210
strPathExe := APathExecutable;
204-
FSuitePathWorking := ExtractFilePath(strPathExe);
211+
FSuitePathASuiteFolder := ExtractFilePath(strPathExe);
205212

206213
strFileListSql := ExtractFileNameOnly(strPathExe) + EXT_SQL;
207214
strFileListXml := ExtractFileNameOnly(strPathExe) + EXT_XML;
@@ -212,18 +219,18 @@ constructor TConfigPaths.Create(APathExecutable: string);
212219
//In Linux, use the folder path of asuite
213220
FSuiteDrive := FSuitePathWorking;
214221
{$ENDIF}
215-
SetCurrentDir(FSuitePathWorking);
222+
SetCurrentDir(FSuitePathASuiteFolder);
216223

217224
//If ASuite is started from a hard linked folder, it will be falsely unwritable
218225
//The user is unlikely to create a hard link for ASuite unless they use Scoop
219226
//In this case, however, the .sqlite files will already exist and you can
220227
//safely use them
221-
if (IsDirectoryWritable(FSuitePathWorking)) or FileExists(FSuitePathWorking + strFileListXml) or
222-
FileExists(FSuitePathWorking + strFileListSql) then
223-
FSuitePathData := FSuitePathWorking
228+
if (IsDirectoryWritable(FSuitePathASuiteFolder)) or FileExists(FSuitePathASuiteFolder + strFileListXml) or
229+
FileExists(FSuitePathASuiteFolder + strFileListSql) then
230+
FSuitePathData := FSuitePathASuiteFolder
224231
else begin
225-
//FSuitePathWorking = ASuite.exe folder (ex C:\path\to\asuite_folder\)
226-
//FSuitePathData = ASuite config folder (ex. C:\Users\user\AppData\Roaming\asuite\)
232+
//FSuitePathASuiteFolder = ASuite.exe folder (ex C:\path\to\asuite_folder\)
233+
//FSuitePathData = ASuite config folder (ex. C:\Users\user\AppData\Roaming\asuite\)
227234
FSuitePathData := GetAppConfigDir(True);
228235
SysUtils.ForceDirectories(FSuitePathData);
229236
end;
@@ -285,7 +292,7 @@ function TConfigPaths.RelativeToAbsolute(const APath: String;
285292
//Note: Unfortunately old asuite vars is not quoted, but in format $var.
286293
// So these two vars are deprecated. This code remain for only backwards compatibility
287294
//CONST_PATH_ASuite_old = Launcher's path
288-
Result := StringReplace(Result, CONST_PATH_ASuite_old, ExcludeTrailingPathDelimiter(SuitePathWorking), [rfIgnoreCase,rfReplaceAll]);
295+
Result := StringReplace(Result, CONST_PATH_ASuite_old, ExcludeTrailingPathDelimiter(FSuitePathASuiteFolder), [rfIgnoreCase,rfReplaceAll]);
289296
//CONST_PATH_DRIVE_old = Launcher's Drive (ex. ASuite in H:\Software\ASuite.exe, CONST_PATH_DRIVE is H: )
290297
Result := StringReplace(Result, CONST_PATH_DRIVE_old, SUITEDRIVE, [rfIgnoreCase,rfReplaceAll]);
291298

Library/Kernel.Consts.pas

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ interface
3939
MENUTHEMES_DIR = 'themes';
4040
ICONS_DIR = 'icons';
4141
BUTTONS_DIR = 'buttons';
42+
DOCS_DIR = 'docs';
4243

4344
//FileSystem
4445
DriveLetters = ['a'..'z', 'A'..'Z'];

0 commit comments

Comments
 (0)