I agree with mormanman but anyway.. here's a sample updater.. Install: http://nala.villavu.com/downloads/ma...i386-win32.exe to use it..
It downloads your github repo to Simba's includes as a zip file. It unzips it and deletes the zip file. Checks if newer versions exists or not. If it doesn't it'll download it otherwise it won't. If no version exists, it installs it fresh. Works for any and all repos. If an error occurs, it calls onUpdateComplete with Success set to false and Error string set to the error description. Otherwise it calls it with Success set to true and Error set to "Success".
Simba Code:
Procedure onUpdateComplete(Success: Boolean; Error: String);
begin
if (Not Success) then
writeln('An error occurred: ' + Error)
else
writeln(Error);
end;
Procedure Update(GitURL: String; VersionFile: String; onComplete: Procedure(Success: Boolean; Error: String));
const
GitHead = 'https://github.com/';
RawGitHead = 'https://raw.githubusercontent.com/';
MasterHead = 'https://codeload.github.com/';
MasterFoot = '/zip/master';
var
hFile, hZip, I, J, P: Integer;
ZipData: String;
RepoName, VersionPath: String;
Version, Error, GitVersion: String;
Label DownloadLabel;
Begin
P := -1;
For I := 1 To Length(GitURL) Do
If (GitURL[I] = '/') Then
P := I + 1;
If (P <> -1) Then
Begin
RepoName := Copy(GitURL, P, Length(GitURL) - P + 1);
VersionPath := IncludePath + RepoName + '\' + VersionFile;
If (Not FileExists(VersionPath)) Then
Goto DownloadLabel;
hFile := OpenFile(VersionPath, True);
If (hFile = -1) Then
Begin
onUpdateComplete(False, 'Cannot Open File: ' + VersionPath);
Exit;
End;
SetLength(Version, 10);
If (Not ReadFileString(hFile, Version, 5)) Then
Begin
CloseFile(hFile);
onUpdateComplete(False, 'Cannot Read File: ' + VersionPath);
Exit;
End;
If (Length(Version) < 1) Then
Begin
CloseFile(hFile);
onUpdateComplete(False, 'File: ' + VersionPath + ' is empty.');
Exit;
End;
GitVersion := Copy(GitURL, Length(GitHead) + 1, Length(GitURL) - Length(GitHead) + 1);
GitVersion := RawGitHead + GitVersion + '/master/' + VersionFile;
VersionPath := GitVersion;
GitVersion := Trim(GetPage(VersionPath));
If ((Length(GitVersion) < 1) or (GitVersion = 'Not Found')) Then
Begin
CloseFile(hFile);
onUpdateComplete(False, 'File: ' + VersionPath + ' is empty or does not exist.');
Exit;
End;
If (GitVersion <> Version) Then
Begin
onUpdateComplete(True, 'Already up-to-date.');
Exit;
End;
DownloadLabel:
ZipData := Copy(GitURL, Length(GitHead) + 1, Length(GitURL) - Length(GitHead) + 1);
ZipData := GetPage(MasterHead + ZipData + MasterFoot);
hZip := RewriteFile(IncludePath + RepoName + '.zip', False);
If (hZip <> -1) Then
Begin
If (Not WriteFileString(hZip, ZipData)) Then
Begin
onUpdateComplete(False, 'Cannot write archive.');
Exit;
End;
If (hFile <> 0) Then
CloseFile(hFile);
CloseFile(hZip);
UnzipFile(IncludePath + RepoName + '.zip', IncludePath);
DeleteFile(IncludePath + RepoName + '.zip');
RenameFile(IncludePath + RepoName + '-master', IncludePath + RepoName);
onUpdateComplete(True, 'Successfully updated.');
Exit;
End Else
Begin
If (hFile <> 0) Then
CloseFile(hFile);
If (hZip <> 0) Then
CloseFile(hZip);
onUpdateComplete(False, 'Cannot open archive.');
Exit;
End;
If (hFile <> 0) Then
CloseFile(hFile);
End;
End;
begin
Update('https://github.com/J-Flight/AeroLib', 'VERSION', @onUpdateComplete);
end.