aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam Harrison <adamdharrison@gmail.com>2023-06-09 10:19:44 -0400
committerAdam Harrison <adamdharrison@gmail.com>2023-06-09 10:19:44 -0400
commitdb5c0e1d47d9ba0e177c278b4c52143069b7cfe9 (patch)
treec01068a2ecb249d4ca10cd1dd73aae8a8104263a /src
parent872b66996c6423a85ddccc905ce7382caa9264a7 (diff)
downloadlite-xl-plugin-manager-db5c0e1d47d9ba0e177c278b4c52143069b7cfe9.tar.gz
lite-xl-plugin-manager-db5c0e1d47d9ba0e177c278b4c52143069b7cfe9.zip
Made things clearer.
Diffstat (limited to 'src')
-rw-r--r--src/lpm.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/lpm.c b/src/lpm.c
index 4d1e773..0944963 100644
--- a/src/lpm.c
+++ b/src/lpm.c
@@ -231,15 +231,14 @@ static int lpm_mkdir(lua_State *L) {
static int lpm_stat(lua_State *L) {
const char *path = luaL_checkstring(L, 1);
- char fullpath[MAX_PATH];
#ifdef _WIN32
+ wchar_t fullpath[MAX_PATH];
struct _stat s;
LPCWSTR wpath = lua_toutf16(L, path);
int err = _wstat(wpath, &s);
- LPCWSTR wfullpath = _wfullpath(fullpath, wpath, MAX_PATH);
- if (!wfullpath) return 0;
- const char *abs_path = lua_toutf8(L, wfullpath);
+ const char *abs_path = !err && _wfullpath(fullpath, wpath, MAX_PATH) ? lua_toutf8(L, (LPCWSTR)fullpath) : NULL;
#else
+ char fullpath[MAX_PATH];
struct stat s;
int err = lstat(path, &s);
const char *abs_path = !err ? realpath(path, fullpath) : NULL;