From c89f82614f8093dd92d1314602d700b74fdb3e31 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 7 Jan 2025 09:29:18 +0300 Subject: [PATCH] filesystem: wscript: check d_type field in struct dirent, as this is an extension and some supported ports (like psvita) don't have it --- filesystem/filesystem.c | 3 ++- filesystem/wscript | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/filesystem/filesystem.c b/filesystem/filesystem.c index 9fd30d9365..cce3cf6a4e 100644 --- a/filesystem/filesystem.c +++ b/filesystem/filesystem.c @@ -261,9 +261,10 @@ void listdirectory( stringlist_t *list, const char *path, qboolean dirs_only ) // iterate through the directory while(( entry = readdir( dir ))) { - // FIXME: this is a BSD extension, add check to wscript +#if HAVE_DIRENT_D_TYPE if( dirs_only && entry->d_type != DT_DIR && entry->d_type != DT_UNKNOWN ) continue; +#endif stringlistappend( list, entry->d_name ); } diff --git a/filesystem/wscript b/filesystem/wscript index 3013a5383e..bddf72cc2c 100644 --- a/filesystem/wscript +++ b/filesystem/wscript @@ -4,6 +4,11 @@ MEMFD_CREATE_TEST = '''#define _GNU_SOURCE #include int main(int argc, char **argv) { return memfd_create(argv[0], 0); }''' +DIRENT_D_TYPE_TEST = '''#define _GNU_SOURCE +#include +int main(int argc, char **argv) { struct dirent entry; entry.d_type = DT_DIR; return 0; } +''' + def options(opt): pass @@ -18,6 +23,9 @@ def configure(conf): if conf.check_cc(fragment=MEMFD_CREATE_TEST, msg='Checking for memfd_create', mandatory=False): conf.define('HAVE_MEMFD_CREATE', 1) + if conf.check_cc(fragment=DIRENT_D_TYPE_TEST, msg='Checking for d_type field in struct dirent', mandatory=False): + conf.define('HAVE_DIRENT_D_TYPE', 1) + def build(bld): bld(name = 'filesystem_includes', export_includes = '.')