diff options
author | Adam <adamdharrison@gmail.com> | 2022-09-27 20:38:29 -0400 |
---|---|---|
committer | Adam <adamdharrison@gmail.com> | 2022-09-27 20:38:29 -0400 |
commit | d6a4e9f4904ceff72c04d147d9abe78586e4d139 (patch) | |
tree | 515bcc921310dd7c6c3a732979e09747eabce41b /lpm.c | |
parent | 8cf423ce22e03e3d5bfc87ece071bdc27a36ad8b (diff) | |
download | lite-xl-plugin-manager-d6a4e9f4904ceff72c04d147d9abe78586e4d139.tar.gz lite-xl-plugin-manager-d6a4e9f4904ceff72c04d147d9abe78586e4d139.zip |
Bottles now working.
Diffstat (limited to 'lpm.c')
-rw-r--r-- | lpm.c | 26 |
1 files changed, 16 insertions, 10 deletions
@@ -269,7 +269,7 @@ static int lpm_stat(lua_State *L) { free(wpath); #else struct stat s; - int err = stat(path, &s); + int err = lstat(path, &s); #endif if (err < 0) { lua_pushnil(L); @@ -278,6 +278,21 @@ static int lpm_stat(lua_State *L) { } lua_newtable(L); +#if __linux__ + if (S_ISLNK(s.st_mode)) { + char buffer[PATH_MAX]; + ssize_t len = readlink(path, buffer, sizeof(buffer)); + if (len < 0) + return 0; + lua_pushlstring(L, buffer, len); + } else + lua_pushnil(L); + lua_setfield(L, -2, "symlink"); + if (S_ISLNK(s.st_mode)) + err = stat(path, &s); + if (err) + return 1; +#endif lua_pushinteger(L, s.st_mtime); lua_setfield(L, -2, "modified"); @@ -292,15 +307,6 @@ static int lpm_stat(lua_State *L) { lua_pushnil(L); } lua_setfield(L, -2, "type"); - -#if __linux__ - if (S_ISDIR(s.st_mode)) { - if (lstat(path, &s) == 0) { - lua_pushboolean(L, S_ISLNK(s.st_mode)); - lua_setfield(L, -2, "symlink"); - } - } -#endif return 1; } /** END STOLEN LITE CODE **/ |