From 7092a0a8f07c0ad6dd096294e7a170663e7378a9 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 12 Jan 2020 23:03:59 +0200 Subject: [PATCH] - fixed Linux and macOS implementations of I_FindAttr() At the moment, we assume that dirent struct has d_type member, and DT_DIR is defined This is true for supported versions of macOS, and Linux with glibc https://forum.zdoom.org/viewtopic.php?t=66945 --- src/posix/cocoa/i_system.mm | 9 +-------- src/posix/sdl/i_system.cpp | 9 +-------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/posix/cocoa/i_system.mm b/src/posix/cocoa/i_system.mm index e284434906..723d49b2fd 100644 --- a/src/posix/cocoa/i_system.mm +++ b/src/posix/cocoa/i_system.mm @@ -252,14 +252,7 @@ int I_FindClose(void* const handle) int I_FindAttr(findstate_t* const fileinfo) { dirent* const ent = fileinfo->namelist[fileinfo->current]; - bool isdir; - - if (DirEntryExists(ent->d_name, &isdir)) - { - return isdir ? FA_DIREC : 0; - } - - return 0; + return (ent->d_type & DT_DIR) ? FA_DIREC : 0; } diff --git a/src/posix/sdl/i_system.cpp b/src/posix/sdl/i_system.cpp index f5ba03c2ad..f96d156865 100644 --- a/src/posix/sdl/i_system.cpp +++ b/src/posix/sdl/i_system.cpp @@ -352,14 +352,7 @@ int I_FindClose (void *handle) int I_FindAttr(findstate_t* const fileinfo) { dirent* const ent = fileinfo->namelist[fileinfo->current]; - bool isdir; - - if (DirEntryExists(ent->d_name, &isdir)) - { - return isdir ? FA_DIREC : 0; - } - - return 0; + return (ent->d_type & DT_DIR) ? FA_DIREC : 0; } void I_PutInClipboard (const char *str)