aboutsummaryrefslogtreecommitdiff
path: root/src/lpm.c
diff options
context:
space:
mode:
authorAdam Harrison <adamdharrison@gmail.com>2022-12-27 23:37:30 -0500
committerAdam Harrison <adamdharrison@gmail.com>2022-12-27 23:37:30 -0500
commit966e02a42546949170a1deb5e38dc93b63fdf6fb (patch)
tree17b2d74611cd6ebb37af43585e4a8bc6c7455172 /src/lpm.c
parent37e00da1c6714346487eb1a0ec21afe704f712ef (diff)
downloadlite-xl-plugin-manager-966e02a42546949170a1deb5e38dc93b63fdf6fb.tar.gz
lite-xl-plugin-manager-966e02a42546949170a1deb5e38dc93b63fdf6fb.zip
Added in "post" key.
Diffstat (limited to 'src/lpm.c')
-rw-r--r--src/lpm.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lpm.c b/src/lpm.c
index 076f5ef..79549bf 100644
--- a/src/lpm.c
+++ b/src/lpm.c
@@ -788,6 +788,19 @@ static int lpm_get(lua_State* L) {
return 2;
}
+static int lpm_chdir(lua_State* L) {
+ if (chdir(luaL_checkstring(L, 1)))
+ return luaL_error(L, "error chdiring: %s", strerror(errno));
+ return 0;
+}
+
+static int lpm_pwd(lua_State* L) {
+ char buffer[MAX_PATH];
+ if (!getcwd(buffer, sizeof(buffer)))
+ return luaL_error(L, "error getcwd: %s", strerror(errno));
+ lua_pushstring(L, buffer);
+ return 1;
+}
static const luaL_Reg system_lib[] = {
{ "ls", lpm_ls }, // Returns an array of files.
@@ -803,6 +816,8 @@ static const luaL_Reg system_lib[] = {
{ "get", lpm_get }, // HTTP(s) GET request.
{ "extract", lpm_extract }, // Extracts .tar.gz, and .zip files.
{ "certs", lpm_certs }, // Sets the SSL certificate chain folder/file.
+ { "chdir", lpm_chdir }, // Changes directory. Only use for --post actions.
+ { "pwd", lpm_pwd }, // Gets existing directory. Only use for --post actions.
{ NULL, NULL }
};