summaryrefslogtreecommitdiff
path: root/src/loadlib.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/loadlib.js')
-rw-r--r--src/loadlib.js19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/loadlib.js b/src/loadlib.js
index f25e5dc..a161d49 100644
--- a/src/loadlib.js
+++ b/src/loadlib.js
@@ -217,6 +217,22 @@ const searchpath = function(L, name, path, sep, dirsep) {
return null; /* not found */
};
+const ll_searchpath = function(L) {
+ let f = searchpath(
+ L,
+ lauxlib.luaL_checkstring(L, 1),
+ lauxlib.luaL_checkstring(L, 2),
+ lauxlib.luaL_optstring(L, 3, [".".charCodeAt(0)]),
+ lauxlib.luaL_optstring(L, 4, [lua.LUA_DIRSEP.charCodeAt(0)])
+ );
+ if (f !== null) return 1;
+ else { /* error message is on top of the stack */
+ lua.lua_pushnil(L);
+ lua.lua_insert(L, -2);
+ return 2; /* return nil + error message */
+ }
+};
+
const findfile = function(L, name, pname, dirsep) {
lua.lua_getfield(L, lua.lua_upvalueindex(1), pname);
let path = lua.lua_tostring(L, -1);
@@ -348,7 +364,8 @@ const ll_require = function(L) {
};
const pk_funcs = {
- "loadlib": ll_loadlib
+ "loadlib": ll_loadlib,
+ "searchpath": ll_searchpath
};
const ll_funcs = {