Lunatic-m32: take over load path.

git-svn-id: https://svn.eduke32.com/eduke32@3059 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-10-07 15:26:09 +00:00
parent 2851f412d2
commit 36687ab986
3 changed files with 39 additions and 0 deletions

View File

@ -263,6 +263,18 @@ static searchpath_t *searchpathhead = NULL;
static size_t maxsearchpathlen = 0;
int32_t pathsearchmode = 0;
char *listsearchpath(int32_t initp)
{
static searchpath_t *sp;
if (initp)
sp = searchpathhead;
else if (sp != NULL)
sp = sp->next;
return sp ? sp->path : NULL;
}
int32_t addsearchpath(const char *p)
{
struct stat st;

View File

@ -29,3 +29,26 @@ sectorsofbunch = defs_c.sectorsofbunch
getbunch = defs_c.getbunch
hitscan = defs_c.hitscan
--== Mapster32-specific initialization
ffi.cdef "char *listsearchpath(int32_t initp);"
-- Add the search path directories to the Lua load path.
local initp = 1
while (true) do
local sp_c = ffiC.listsearchpath(initp)
if (sp_c == nil) then
break
end
local sp = ffi.string(sp_c)
assert(sp:sub(-1)=='/')
package.path = sp..'?.lua;'..package.path
initp = 0
end
--print('Lua load path: '..package.path)

View File

@ -32,4 +32,8 @@ hitscan;
rotatesprite;
gethitickms;
listsearchpath;
};