diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2010-08-13 07:58:56 +0200 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2010-08-13 07:59:08 +0200 |
commit | 2de1daae9e11f61400e7f6685079c491d166ac88 (patch) | |
tree | f742cf0631d8405c2da7f731261cb09550356346 /src | |
parent | 4dcf73f8e320b9fd654229cd355fb645df24ed93 (diff) |
Adding searchpath to LuaLoadPlugin
Diffstat (limited to 'src')
-rw-r--r-- | src/lua-plugin.cc | 12 | ||||
-rw-r--r-- | src/lua-plugin.h | 2 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/lua-plugin.cc b/src/lua-plugin.cc index 1e4ebc7..3c08201 100644 --- a/src/lua-plugin.cc +++ b/src/lua-plugin.cc @@ -15,7 +15,7 @@ typedef void(*init_ptr_t)(Lua *); #include <windows.h> #include "MemoryModule.h" -void LuaLoadPlugin(const String & _fname, Lua * L) throw (GeneralException) { +void LuaLoadPlugin(const String & _fname, const String & searchpath, Lua * L) throw (GeneralException) { HMODULE handle; String fname = _fname + "." SHARED_EXT; @@ -67,15 +67,19 @@ void LuaLoadPlugin(Handle * h, Lua * L) throw (GeneralException) { #else #include <dlfcn.h> -void LuaLoadPlugin(const String & fname, Lua * L) throw (GeneralException) { +void LuaLoadPlugin(const String & fname, const String & searchpath, Lua * L) throw (GeneralException) { String full_fname = "./" + fname + "." SHARED_EXT; void * handle = dlopen(full_fname.to_charp(), RTLD_NOW | RTLD_GLOBAL); Base::printm(M_INFO, "Loading library " + fname + "\n"); if (!handle) { - LuaLoadPlugin(&Input(fname + "." SHARED_EXT), L); - return; + full_fname = searchpath + fname + "." SHARED_EXT + handle = dlopen(full_fname.to_charp(), RTLD_NOW | RTLD_GLOBAL); + if (!handle) { + LuaLoadPlugin(&Input(fname + "." SHARED_EXT), L); + return; + } } init_ptr_t init_ptr = (init_ptr_t) dlsym(handle, "init_plugin"); diff --git a/src/lua-plugin.h b/src/lua-plugin.h index e347b6b..9e4ed4c 100644 --- a/src/lua-plugin.h +++ b/src/lua-plugin.h @@ -5,7 +5,7 @@ #include <Exceptions.h> #include <Handle.h> -void LuaLoadPlugin(const String & fname, Lua * L) throw (GeneralException); +void LuaLoadPlugin(const String & fname, const String & searchpath, Lua * L) throw (GeneralException); void LuaLoadPlugin(Handle * h, Lua * L) throw (GeneralException); #endif |