diff options
author | Benjamin FRANCOIS <kwyxz@kwyxz.org> | 2021-05-09 14:03:46 -0700 |
---|---|---|
committer | Benjamin FRANCOIS <kwyxz@kwyxz.org> | 2021-05-09 14:03:46 -0700 |
commit | b0bc05ad23adcf977865ad445fd35bcb4e6c11c2 (patch) | |
tree | 4ed8586dfea07454179e552bc502c4a8cf22578d | |
parent | e70b05bf5b5954140cba227fc996ab24c064d494 (diff) |
Allow Haiku build
-rw-r--r-- | util.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -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; |