From 2fdbd86a7fc012558f2d18bc1bc3f8bc0ba17a4f Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Thu, 22 Dec 2011 21:30:05 +0000 Subject: [PATCH] Add aegisub.decode_path, which simply wraps StandardPaths::DecodePath Originally committed to SVN as r6130. --- aegisub/src/auto4_lua.cpp | 11 +++++++++++ aegisub/src/auto4_lua.h | 1 + 2 files changed, 12 insertions(+) diff --git a/aegisub/src/auto4_lua.cpp b/aegisub/src/auto4_lua.cpp index aed29752d..aee529a9a 100644 --- a/aegisub/src/auto4_lua.cpp +++ b/aegisub/src/auto4_lua.cpp @@ -65,6 +65,7 @@ #include "include/aegisub/context.h" #include "main.h" #include "selection_controller.h" +#include "standard_paths.h" #include "video_context.h" #include "utils.h" @@ -262,6 +263,7 @@ namespace Automation4 { set_field(L, "ms_from_frame", LuaMsFromFrame); set_field(L, "video_size", LuaVideoSize); set_field(L, "keyframes", LuaGetKeyframes); + set_field(L, "decode_path", LuaDecodePath); set_field(L, "lua_automation_version", 4); // store aegisub table to globals @@ -511,6 +513,15 @@ namespace Automation4 { return 1; } + int LuaScript::LuaDecodePath(lua_State *L) + { + const agi::Context *c = get_context(L); + wxString path = check_wxstring(L, 1); + lua_pop(L, 1); + lua_pushstring(L, StandardPaths::DecodePath(path).utf8_str()); + return 1; + } + static void lua_threaded_call(ProgressSink *ps, lua_State *L, int nargs, int nresults, bool can_open_config, bool *failed) { LuaProgressSink lps(L, ps, can_open_config); diff --git a/aegisub/src/auto4_lua.h b/aegisub/src/auto4_lua.h index d78fbd463..c063c8f2a 100644 --- a/aegisub/src/auto4_lua.h +++ b/aegisub/src/auto4_lua.h @@ -310,6 +310,7 @@ namespace Automation4 { static int LuaMsFromFrame(lua_State *L); static int LuaVideoSize(lua_State *L); static int LuaGetKeyframes(lua_State *L); + static int LuaDecodePath(lua_State *L); public: LuaScript(const wxString &filename);