aboutsummaryrefslogtreecommitdiff
path: root/src/lpm.c
diff options
context:
space:
mode:
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);