File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -10,20 +10,27 @@ if SYSTEM=='Linux' then
10
10
end
11
11
end
12
12
13
- ---
13
+ local function defaultErrorHandler (errInfo )
14
+ for i = 1 ,# errInfo do
15
+ MSG .errorLog (errInfo [i ])
16
+ end
17
+ end
18
+
19
+ --- A wrapped ffi.load that will try to load FMOD library in different paths with an error handler receiving all error informations
14
20
--- @param name string name of the library , ' fmod' for ' fmod.dll' | ' libfmod.so'
15
- --- @return ffi.namespace*
16
- --- @overload fun ( name : string ): result : false,errInfo : string[]
17
- return function (name )
21
+ --- @param handler ? fun ( errLog : string[] ) will call this if loading failed
22
+ --- @return ffi.namespace* | false
23
+ return function (name , handler )
18
24
local errLog = {}
19
25
for i = 1 ,# path do
20
26
local suc ,res
21
27
suc ,res = pcall (ffi .load ,STRING .repD (path [i ],name ))
22
28
if suc then
23
29
return res
24
30
else
25
- table.insert (errLog ," Loading FMOD lib: " .. res )
31
+ table.insert (errLog ,STRING . repD ( " ffi.load('$1'): $2 " , name , res ) )
26
32
end
27
33
end
28
- return false ,errLog
34
+ (type (handler )== ' function' and handler or defaultErrorHandler )(errLog )
35
+ return false
29
36
end
You can’t perform that action at this time.
0 commit comments