forked from bmx-ng/bmk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bmk_ng_utils.bmx
172 lines (133 loc) · 3.62 KB
/
bmk_ng_utils.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
SuperStrict
Import BRL.MaxUtil
Import BRL.FileSystem
?Not linux
Import BRL.System
?
Import BRL.MaxLua
?linux
Import "bmk_cores_linux.bmx"
?macos
Import "bmk_cores_macos.bmx"
?win32
Import "bmk_cores_win32.bmx"
?
Global utils:TMaxUtils = New TMaxUtils
Global fsys:TSystem = New TSystem
' Access to BRL.MaxUtil
Type TMaxUtils
Method New()
LuaRegisterObject Self,"utils"
End Method
Method BlitzMaxPath:String()
Return BRL.MaxUtil.BlitzMaxPath()
End Method
Method ModulePath:String( modid$ )
Return BRL.MaxUtil.ModulePath(modid)
End Method
Method ModuleIdent:String( modid$ )
Return BRL.MaxUtil.ModuleIdent(modid)
End Method
Method ModuleSource:String( modid$ )
Return BRL.MaxUtil.ModuleSource(modid)
End Method
Method ModuleArchive:String( modid$,mung$="" )
Return BRL.MaxUtil.ModuleArchive(modid, mung)
End Method
Method ModuleInterface:String( modid$,mung$="" )
Return BRL.MaxUtil.ModuleInterface(modid, mung)
End Method
End Type
' Access to BRL.FileSystem and BRL.System
Type TSystem
Method New()
LuaRegisterObject Self,"sys"
End Method
Method FixPath:String(path:String, dirPath:Int = False)
Local p:String = path
BRL.FileSystem.FixPath(p, dirPath)
Return p
End Method
Method StripDir$( path$ )
Return BRL.FileSystem.StripDir(path)
End Method
Method StripExt$( path$ )
Return BRL.FileSystem.StripExt(path)
End Method
Method StripAll$( path$ )
Return BRL.FileSystem.StripAll(path)
End Method
Method StripSlash$( path$ )
Return BRL.FileSystem.StripSlash(path)
End Method
Method ExtractDir$( path$ )
Return BRL.FileSystem.ExtractDir(path)
End Method
Method ExtractExt$( path$ )
Return BRL.FileSystem.ExtractExt(path)
End Method
Method CurrentDir$()
Return BRL.FileSystem.CurrentDir()
End Method
Method RealPath$( path$ )
Return BRL.FileSystem.RealPath(path)
End Method
Method FileType:Int( path$ )
Return BRL.FileSystem.FileType(path)
End Method
Method CreateFile:Int( path$ )
Return BRL.FileSystem.CreateFile(path)
End Method
Method CreateDir:Int( path$,recurse:Int=False )
Return BRL.FileSystem.CreateDir(path, recurse)
End Method
Method DeleteFile:Int( path$ )
Return BRL.FileSystem.DeleteFile(path)
End Method
Method RenameFile:Int( oldpath$,newpath$ )
Return BRL.FileSystem.RenameFile(oldpath, newpath)
End Method
Method CopyFile:Int( src$,dst$ )
Return BRL.FileSystem.CopyFile(src, dst)
End Method
Method CopyDir:Int( src$,dst$ )
Return BRL.FileSystem.CopyDir(src, dst)
End Method
Method DeleteDir:Int( path$,recurse:Int=False )
Return BRL.FileSystem.DeleteDir(path, recurse)
End Method
Method ChangeDir:Int( path$ )
Return BRL.FileSystem.ChangeDir(path)
End Method
?Not linux
' System
Method CurrentDate:String()
Return BRL.System.CurrentDate()
End Method
Method CurrentTime:String()
Return BRL.System.CurrentTime()
End Method
Method Notify(text:String, serious:Int = False)
BRL.System.Notify(text, serious)
End Method
Method OpenURL(url:String)
BRL.System.OpenURL(url)
End Method
?linux
Method CurrentDate:String(_format$="%d %b %Y")
Local time:Byte[256],buff:Byte[256]
time_(time)
strftime_(buff,256,_format,localtime_( time ))
Return String.FromCString(buff)
End Method
Method CurrentTime:String()
Local time:Byte[256],buff:Byte[256]
time_(time)
strftime_( buff,256,"%H:%M:%S",localtime_( time ) );
Return String.FromCString(buff)
End Method
Method Notify(text:String, serious:Int = False)
WriteStdout text+"~r~n"
End Method
?
End Type