diff options
Diffstat (limited to 'src/pow_lua.c')
| -rw-r--r-- | src/pow_lua.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/pow_lua.c b/src/pow_lua.c index 1d2f81a..0cd1019 100644 --- a/src/pow_lua.c +++ b/src/pow_lua.c @@ -228,7 +228,26 @@ int pow_lua_install(lua_State *L) { return 1; } -luaL_Reg libpow[] = {{"extract", pow_lua_extract}, {"install", pow_lua_install}, {NULL, NULL}}; +int pow_lua_chdir(lua_State *L) { + if (!lua_isstring(L, 1)) { + lua_pushnil(L); + lua_pushstring(L, "arg 1 must be string for chdir"); + + return 2; + } + + char *dir = lua_tostring(L, -1); + + int result = chdir(dir); + + if (result) { + pow_log_error("failed to chdir %d", result); + } + + return 1; +} + +luaL_Reg libpow[] = {{"chdir", pow_lua_chdir}, {"extract", pow_lua_extract}, {"install", pow_lua_install}, {NULL, NULL}}; int pow_lua_load(lua_State *L, pow_config *cfg) { luaL_newlib(L, libpow); |
