From f9906ae6cd3a71a22a3e3dd6aaabf46bb3e400d9 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 26 Jan 2020 11:03:28 +0200 Subject: [PATCH] - fixed I_FindAttr() to handle symlinks on POSIX platforms --- src/posix/i_system.h | 3 ++- src/posix/i_system_posix.cpp | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/posix/i_system.h b/src/posix/i_system.h index 7e5770b52d..e4c3d68dbf 100644 --- a/src/posix/i_system.h +++ b/src/posix/i_system.h @@ -111,9 +111,10 @@ bool I_SetCursor(FTexture *); struct findstate_t { private: - int count; + FString path; struct dirent **namelist; int current; + int count; friend void *I_FindFirst(const char *filespec, findstate_t *fileinfo); friend int I_FindNext(void *handle, findstate_t *fileinfo); diff --git a/src/posix/i_system_posix.cpp b/src/posix/i_system_posix.cpp index 7c65143958..a3b3563177 100644 --- a/src/posix/i_system_posix.cpp +++ b/src/posix/i_system_posix.cpp @@ -19,14 +19,13 @@ //----------------------------------------------------------------------------- // -#include -#include #include #ifdef __APPLE__ #include #endif // __APPLE__ +#include "cmdlib.h" #include "d_protocol.h" #include "i_system.h" #include "gameconfigfile.h" @@ -90,6 +89,7 @@ void *I_FindFirst(const char *const filespec, findstate_t *const fileinfo) { pattern = slash + 1; dir = FString(filespec, slash - filespec + 1); + fileinfo->path = dir; } else { @@ -142,7 +142,15 @@ int I_FindClose(void *const handle) int I_FindAttr(findstate_t *const fileinfo) { dirent *const ent = fileinfo->namelist[fileinfo->current]; - return (ent->d_type & DT_DIR) ? FA_DIREC : 0; + const FString path = fileinfo->path + ent->d_name; + bool isdir; + + if (DirEntryExists(path, &isdir)) + { + return isdir ? FA_DIREC : 0; + } + + return 0; }