Skip to content

Commit

Permalink
filesystem: wscript: check d_type field in struct dirent, as this is …
Browse files Browse the repository at this point in the history
…an extension and some supported ports (like psvita) don't have it
  • Loading branch information
a1batross committed Jan 7, 2025
1 parent cb42a0f commit c89f826
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion filesystem/filesystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down
8 changes: 8 additions & 0 deletions filesystem/wscript
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ MEMFD_CREATE_TEST = '''#define _GNU_SOURCE
#include <sys/mman.h>
int main(int argc, char **argv) { return memfd_create(argv[0], 0); }'''

DIRENT_D_TYPE_TEST = '''#define _GNU_SOURCE
#include <dirent.h>
int main(int argc, char **argv) { struct dirent entry; entry.d_type = DT_DIR; return 0; }
'''

def options(opt):
pass

Expand All @@ -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 = '.')

Expand Down

0 comments on commit c89f826

Please sign in to comment.