diff options
| author | forever2k38 <forever2k38@forever2k38.net> | 2026-10-01 15:44:53 +0200 |
|---|---|---|
| committer | forever2k38 <forever2k38@forever2k38.net> | 2026-10-01 15:44:53 +0200 |
| commit | eb83bf8fd18946c4358f784fa39dad0731a6220a (patch) | |
| tree | c9d0eb2b80ec3975c869ea7733d688599a2ff4be /src | |
| parent | f113371523bc26e320e5ef8799e6ab123af9618e (diff) | |
feat: implement chdir function to remove dependency on lfs
Diffstat (limited to 'src')
| -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); |
