diff --git a/filesystem/filesystem.c b/filesystem/filesystem.c index 9fd30d936..cce3cf6a4 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 3013a5383..bddf72cc2 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 = '.')