-
Notifications
You must be signed in to change notification settings - Fork 2
/
UpdateInfo.pas
82 lines (70 loc) · 1.7 KB
/
UpdateInfo.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
73
74
75
76
77
78
79
80
81
82
unit UpdateInfo;
interface
uses
Classes, Types, StrUtils, SysUtils;
type
TUpdateInfo = class
private
FComponents: TStringlist;
FVersions: TStringList;
FSources: TStringlist;
function GetPatcherVersion: string;
public
constructor Create();
destructor Destroy(); override;
procedure LoadFromFile(AFile: string);
property Components: TStringlist read FComponents;
property Versions: TStringList read FVersions;
property Sources: TStringlist read FSources;
property PatcherVersion: string read GetPatcherVersion;
end;
implementation
uses
IniFiles, PatcherVersion;
{ TUpdateInfo }
constructor TUpdateInfo.Create;
begin
FComponents := TStringList.Create();
FVersions := TStringList.Create();
FSources := TStringList.Create();
end;
destructor TUpdateInfo.Destroy;
begin
FComponents.Free;
FVersions.Free;
FSources.Free;
inherited;
end;
function TUpdateInfo.GetPatcherVersion: string;
var
LIndex: Integer;
begin
Result := '0';
LIndex := FComponents.IndexOf(CPatcherName);
if LIndex > -1 then
begin
Result := FVersions[LIndex];
end;
end;
procedure TUpdateInfo.LoadFromFile(AFile: string);
var
LIni: TIniFile;
LSection: string;
begin
if not FileExists(AFile) then
begin
raise Exception.Create('Update file ' + QuotedStr(AFile) + ' does not exists!');
end;
LIni := TIniFile.Create(AFile);
try
LIni.ReadSections(FComponents);
for LSection in FComponents do
begin
FVersions.Add(LIni.ReadString(LSection, 'Version', '0'));
FSources.Add(LIni.ReadString(LSection, 'Source', ''));
end;
finally
LIni.Free;
end;
end;
end.