forked from bmx-ng/bmk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bmk_modinfo.bmx
60 lines (49 loc) · 1.45 KB
/
bmk_modinfo.bmx
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
Strict
Import "bmk_modutil.bmx"
Import "bmk_util.bmx"
Type TInfo
Field info:TList=New TList
Method Find$( key$ )
key=key.ToLower()+":"
For Local t$=EachIn info
If t.ToLower()[..Len(key)]=key Return t[Len(key)..].Trim()
Next
End Method
Method ReadFromStream:TModInfo( stream:TStream )
While Not stream.Eof()
Local t$=stream.ReadLine()
If Not t Return
info.AddLast t
Wend
End Method
End Type
Type TModInfo Extends TInfo
Field name$
Field version#
Field modprivs$
Field modserver$
Field serverinfo:Object
Function CreateFromModule:TModInfo( name$ )
Local path$=ModuleInterface( name,"release."+processor.Platform()+"."+processor.CPU() )
If FileType(path)<>FILETYPE_FILE Return
Local src:TSourceFile=ParseSourceFile( path )
If Not src Return
Local modinfo:TModInfo=New TModInfo
modinfo.name=name
modinfo.info=src.info
modinfo.info.AddFirst "Module: "+name
modinfo.version=Float( modinfo.Find( "Version" ) )
modinfo.modserver=modinfo.Find( "ModServer" )
Return modinfo
End Function
Function CreateFromStream:TModInfo( stream:TStream )
Local modinfo:TModInfo=New TModInfo
modinfo.ReadFromStream stream
modinfo.name=modinfo.Find( "Module" )
If Not modinfo.name Return
modinfo.version=Float( modinfo.Find( "Version" ) )
modinfo.modprivs=modinfo.Find( "ModPrivs" )
modinfo.modserver=modinfo.Find( "ModServer" )
Return modinfo
End Function
End Type