[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Checking whether a shared library has been loaded
- From: Dirk Laurie <dirk.laurie@...>
- Date: Mon, 9 Feb 2015 12:11:06 +0200
I wish to test whether a shared library has already been loaded.
This is the best I can come up with.
is_loaded_library = function (LIB_NAME)
-- returns fully qualified name of loaded library or `false`
for key,val in pairs(debug.getregistry()) do
if type(key)=='userdata' and type(val)=='table' then
for k in pairs(val) do
if type(k)=='string' and k:match(LIB_NAME..'$') then
return k
end
end
end
end
return false
end
Is there a better way?