mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
lua: replace getcwd() implementation
This commit is contained in:
14
player/lua.c
14
player/lua.c
@@ -1088,19 +1088,6 @@ static int script_get_wakeup_pipe(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int script_getcwd(lua_State *L)
|
||||
{
|
||||
char *cwd = mp_getcwd(NULL);
|
||||
if (!cwd) {
|
||||
lua_pushnil(L);
|
||||
lua_pushstring(L, "error");
|
||||
return 2;
|
||||
}
|
||||
lua_pushstring(L, cwd);
|
||||
talloc_free(cwd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int script_readdir(lua_State *L)
|
||||
{
|
||||
// 0 1 2 3
|
||||
@@ -1305,7 +1292,6 @@ static const struct fn_entry main_fns[] = {
|
||||
};
|
||||
|
||||
static const struct fn_entry utils_fns[] = {
|
||||
FN_ENTRY(getcwd),
|
||||
FN_ENTRY(readdir),
|
||||
FN_ENTRY(split_path),
|
||||
FN_ENTRY(join_path),
|
||||
|
||||
@@ -542,4 +542,8 @@ function mp_utils.to_string(v, set)
|
||||
end
|
||||
end
|
||||
|
||||
function mp_utils.getcwd()
|
||||
return mp.get_property("working-directory")
|
||||
end
|
||||
|
||||
return {}
|
||||
|
||||
Reference in New Issue
Block a user