Skip to content

Commit

Permalink
refactoring(path): some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
salvadorbs committed Oct 2, 2024
1 parent 2543334 commit daed480
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
10 changes: 1 addition & 9 deletions Library/AppConfig.Paths.pas
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,12 @@ procedure TConfigPaths.UpdateASuiteVars;

constructor TConfigPaths.Create(APathExecutable: string);
var
strPathExe, strFileListSql, strFileListXml: String;
strPathExe: String;
begin
//Default paths
strPathExe := APathExecutable;
FSuitePathASuiteFolder := ExtractFilePath(strPathExe);

strFileListSql := ExtractFileNameOnly(strPathExe) + EXT_SQL;
strFileListXml := ExtractFileNameOnly(strPathExe) + EXT_XML;

{$IFDEF MSWINDOWS}
FSuiteDrive := LowerCase(ExtractFileDrive(strPathExe));
{$ELSE}
Expand All @@ -235,11 +232,6 @@ constructor TConfigPaths.Create(APathExecutable: string);
SysUtils.ForceDirectories(FSuitePathData);
end;

//Check if xml list exists, else get sqlite list
FSuitePathList := FSuitePathData + strFileListXml;
if not FileExists(FSuitePathList) then
FSuitePathList := FSuitePathData + strFileListSql;

FSuitePathSettings := FSuitePathData + SETTINGS_FILENAME;

//Path variables
Expand Down
23 changes: 19 additions & 4 deletions Library/Kernel.Instance.pas
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ TASuiteInstance = class
implementation

uses
Forms.ImportList, Kernel.Logger, Forms, Kernel.Consts, Utility.FileFolder,
Forms.ImportList, Kernel.Logger, Forms, Kernel.Consts, Utility.FileFolder, LazFileUtils,
Utility.Misc, Utility.XML, VirtualTree.Methods, mormot.core.log, Kernel.Manager,
mormot.core.base, VirtualTrees.Types;

Expand Down Expand Up @@ -105,16 +105,31 @@ function TASuiteInstance.GetSmallHeightNode: Integer;
constructor TASuiteInstance.Create;
var
I: Integer;
strFileListSql, strFileListXml: String;
begin
FScheduler := TScheduler.Create;
FVSTEvents := TVirtualTreeEvents.Create;

//Create some classes
FPaths := TConfigPaths.Create(Application.ExeName);

//Params
for I := 1 to ParamCount do
HandleParam(ParamStr(I));

//Create some classes
FPaths := TConfigPaths.Create(Application.ExeName);
strFileListSql := ExtractFileNameOnly(Application.ExeName) + EXT_SQL;
strFileListXml := ExtractFileNameOnly(Application.ExeName) + EXT_XML;

// Check if FSuitePathList is a empty string
if (FPaths.SuitePathList = '') then
begin
//Check if xml list exists, else get sqlite list
FPaths.SuitePathList := FPaths.SuitePathData + strFileListXml;
if not FileExists(FPaths.SuitePathList) then
FPaths.SuitePathList := FPaths.SuitePathData + strFileListSql;
end
else
FPaths.SuitePathList := FPaths.RelativeToAbsolute(FPaths.SuitePathList);

//Setup logger
with TSynLog.Family do
Expand Down Expand Up @@ -166,7 +181,7 @@ procedure TASuiteInstance.HandleParam(const Param: string;
if sName <> '' then
begin
if (CompareText(sName, 'list') = 0) and (FirstInstance) then
FPaths.SuitePathList := FPaths.RelativeToAbsolute(RemoveAllQuotes(sValue));
FPaths.SuitePathList := RemoveAllQuotes(sValue);

//Add new node
if (CompareText(sName, 'additem') = 0) and (Assigned(ASuiteManager.DBManager)) then
Expand Down

0 comments on commit daed480

Please sign in to comment.