summaryrefslogtreecommitdiffstats
path: root/player/lua.c
diff options
context:
space:
mode:
authorOtto Modinos <ottomodinos@gmail.com>2014-08-31 01:23:03 +0300
committerwm4 <wm4@nowhere>2014-08-31 00:58:27 +0200
commita910b5c6df1c257ae3b4be62030e48ff9ffb6bad (patch)
tree052c72631e8cbc125537bef0b33eba1262065c81 /player/lua.c
parent895687844829068999869326de3cb9174e5fb496 (diff)
downloadmpv-a910b5c6df1c257ae3b4be62030e48ff9ffb6bad.tar.bz2
mpv-a910b5c6df1c257ae3b4be62030e48ff9ffb6bad.tar.xz
lua: expose mp_getcwd through mp.utils
Diffstat (limited to 'player/lua.c')
-rw-r--r--player/lua.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/player/lua.c b/player/lua.c
index dbf0756648..ddcd8acc50 100644
--- a/player/lua.c
+++ b/player/lua.c
@@ -1005,6 +1005,19 @@ 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
@@ -1104,6 +1117,7 @@ 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),