aboutsummaryrefslogtreecommitdiff
path: root/src/lpm.c
diff options
context:
space:
mode:
authorAdam Harrison <adamdharrison@gmail.com>2024-03-17 21:25:20 -0400
committerAdam Harrison <adamdharrison@gmail.com>2024-03-17 21:25:20 -0400
commit4b010fa276dad577094faaca41f4e2690eef8154 (patch)
tree7eb7c7a94f1d740432f0c442f022a8c87ff29a34 /src/lpm.c
parent3f7f832623359acea17fde32eaccc2fc92a21c84 (diff)
downloadlite-xl-plugin-manager-4b010fa276dad577094faaca41f4e2690eef8154.tar.gz
lite-xl-plugin-manager-4b010fa276dad577094faaca41f4e2690eef8154.zip
Added in EXEFILE.
Diffstat (limited to 'src/lpm.c')
-rw-r--r--src/lpm.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/lpm.c b/src/lpm.c
index 8b73cc2..1a8bda8 100644
--- a/src/lpm.c
+++ b/src/lpm.c
@@ -1503,6 +1503,22 @@ int main(int argc, char* argv[]) {
#endif
lua_setglobal(L, "SYSTMPDIR");
+ #if _WIN32
+ wchar_t selfpath[MAX_PATH] = {0};
+ if (GetModuleFileNameW(0, selfpath, MAX_PATH - 1))
+ lua_toutf8(L, selfpath);
+ else
+ lua_pushnil(L);
+ #else
+ char selfpath[MAX_PATH] = {0};
+ int length = readlink("/proc/self/exe", selfpath, MAX_PATH);
+ if (length > 0)
+ lua_pushlstring(L, selfpath, length);
+ else
+ lua_pushnil(L);
+ #endif
+ lua_setglobal(L, "EXEFILE");
+
lua_pushliteral(L, LITE_ARCH_TUPLE);
lua_setglobal(L, "ARCH");
lua_pushliteral(L, LPM_DEFAULT_REPOSITORY);