Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

143 lines (119 sloc) 4.125 kb
program SRLUpdater;
{$I ./Updater.sei}
function CheckSRL(Name: string; I: integer): boolean;
var
X: integer;
begin
Result := True;
for X := 0 to Length(UpdaterArr) do
if (UpdaterArr[X].Name = 'Plugins') then
begin
if (Name = 'Check') then
Tick(UpdaterArr[X].CheckMenuItem)
else
Tick(UpdaterArr[X].Timer);
Exit;
end;
end;
function BeforeUpdate(NotNeeded: string; I: integer): boolean;
begin
Result := ForceDirectories(UpdaterArr[I].Folder + UpdaterArr[I].Name);
end;
function BeforeUpdateEx(NotNeeded: string; I: integer): boolean;
begin
Result := ForceDirectories(UpdaterArr[I].Folder);
end;
function SuccessPlugins(Cont: string; I: integer): boolean;
var
X: integer;
Files: TStringArray;
Overwrite: boolean;
begin
Files := GetFiles(UpdaterArr[I].Folder, {$IFDEF WIN32}'dll'{$ELSE}'so'{$ENDIF});
Overwrite := True;
for X := 0 to High(Files) do
if (FileExists(PluginPath + Files[X])) then
begin
Overwrite := (MessageDlg('SRL Updater', 'Do you want to overwrite the plugins?', mtConfirmation, [mbNo, mbYes], 0) = mrYes);
Break;
end;
if overwrite then
begin
for x := 0 to high(files) do
if FileExists(PluginPath + Files[X]) then
begin
if FileExists(PluginPath + Files[X] + '.bak') then
DeleteFile(PluginPath + Files[X] + '.bak');
if RenameFile(PluginPath + Files[X], PluginPath + Files[X] + '.bak') then
writeln('Renamed ' + PluginPath + Files[X] + ' to ' + PluginPath + Files[X] + '.bak')
else
writeln('Plugins Updater: failed to rename ' + PluginPath + Files[X] + ' to ' +
PluginPath + Files[X] + '.bak');
end;
end;
Result := UnTarEx(Cont, PluginPath, Overwrite);
if not Result then
begin
writeln('********************************************************************************');
writeln('');
writeln('Failed to update plugins! Restart Simba and update before starting a script.');
writeln('');
writeln('********************************************************************************');
end;
end;
procedure ClickMSI(Sender: TObject);
begin
if (not (FileExists(IncludePath + 'msi\RunMe.simba'))) then
begin
WriteLn('MSI: Couldn''t find MSI!');
Exit;
end;
if (TMenuItem(Sender).Caption = 'Run') then
WriteLn('Running MSI...')
else
WriteLn('Opening MSI...');
OpenScriptEx(IncludePath + 'msi\RunMe.simba', (TMenuItem(Sender).Caption = 'Run'));
end;
procedure Init;
var
SRL, SPS, MSI, Plugins, i: integer;
MenuItems: array[0..1] of TMenuItem;
Names: array of string;
begin
if (AddUpdater('SRL', 'http://wizzup.org/static/srl/srl.tar.bz2', 'http://wizzup.org/static/srl/srl_version', IncludePath, True, True, SRL)) then
begin
UpdaterArr[SRL].Hooks[CHECK_FOR_UPDATE] := @CheckSRL;
UpdaterArr[SRL].Hooks[BEFORE_UPDATE] := @BeforeUpdate;
end;
if (AddUpdater('Plugins', 'http://wizzup.org/static/srl/simba_plugins.tar.bz2', 'http://wizzup.org/static/srl/plugins_version', PluginPath + '.temp\', False, False, Plugins)) then
begin
UpdaterArr[Plugins].Hooks[BEFORE_UPDATE] := @BeforeUpdateEx;
UpdaterArr[Plugins].Hooks[SUCCESS_UPDATE] := @SuccessPlugins;
end;
if (AddUpdater('SPS', 'http://wizzup.org/static/srl/sps.tar.bz2', 'http://wizzup.org/static/srl/sps_version', IncludePath, True, True, SPS)) then
begin
UpdaterArr[SPS].Hooks[BEFORE_UPDATE] := @BeforeUpdate;
end;
if (AddUpdater('MSI', 'http://wizzup.org/static/srl/msi.tar.bz2', 'http://wizzup.org/static/srl/msi_version', IncludePath, True, True, MSI)) then
begin
Names := ['Run', 'Open'];
for I := 0 to 1 do
begin
MenuItems[I] := TMenuItem.Create(UpdaterArr[MSI].MainMenu);
MenuItems[I].OnClick := @ClickMSI;
MenuItems[I].Caption := Names[I];
UpdaterArr[MSI].MainMenu.Insert(I, MenuItems[I]);
end;
UpdaterArr[MSI].Hooks[BEFORE_UPDATE] := @BeforeUpdate;
end;
end;
function GetName: string;
begin
Result := 'SRL/SPS/MSI/Plugins Updater';
end;
function GetVersion: string;
begin
Result := '1.0';
end;
begin
end.
Jump to Line
Something went wrong with that request. Please try again.