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
1010 end
1111end
1212
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
1420--- @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 )
1824 local errLog = {}
1925 for i = 1 ,# path do
2026 local suc ,res
2127 suc ,res = pcall (ffi .load ,STRING .repD (path [i ],name ))
2228 if suc then
2329 return res
2430 else
25- table.insert (errLog ," Loading FMOD lib: " .. res )
31+ table.insert (errLog ,STRING . repD ( " ffi.load('$1'): $2 " , name , res ) )
2632 end
2733 end
28- return false ,errLog
34+ (type (handler )== ' function' and handler or defaultErrorHandler )(errLog )
35+ return false
2936end
You can’t perform that action at this time.
0 commit comments