From b0bc05ad23adcf977865ad445fd35bcb4e6c11c2 Mon Sep 17 00:00:00 2001 From: Benjamin FRANCOIS Date: Sun, 9 May 2021 14:03:46 -0700 Subject: Allow Haiku build --- util.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'util.c') diff --git a/util.c b/util.c index 1617551..3d2aaf0 100644 --- a/util.c +++ b/util.c @@ -853,15 +853,27 @@ dir_entry *get_dir_list(char *path, size_t *numret) struct dirent* entry; while (entry = readdir(d)) { +#if defined(__HAIKU__) + struct stat sp; + stat(entry->d_name, &sp); + if (!S_ISREG(sp.st_mode) && !S_ISLNK(sp.st_mode) && !S_ISDIR(sp.st_mode)) { + continue; + } +#else if (entry->d_type != DT_REG && entry->d_type != DT_LNK && entry->d_type != DT_DIR) { continue; } +#endif if (pos == storage) { storage = storage * 2; ret = realloc(ret, sizeof(dir_entry) * storage); } ret[pos].name = strdup(entry->d_name); +#if defined(__HAIKU__) + ret[pos++].is_dir = S_ISDIR(sp.st_mode); +#else ret[pos++].is_dir = entry->d_type == DT_DIR; +#endif } if (numret) { *numret = pos; -- cgit v1.2.3