| 1 |
#ifndef _DIRENT_H |
| 2 |
#define _DIRENT_H |
| 3 |
|
| 4 |
#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ |
| 5 |
#else |
| 6 |
#include <__header_dirent.h> |
| 7 |
#endif |
| 8 |
#ifdef __cplusplus |
| 9 |
extern "C" { |
| 10 |
#endif |
| 11 |
|
| 12 |
#include <features.h> |
| 13 |
|
| 14 |
#define __NEED_ino_t |
| 15 |
#define __NEED_off_t |
| 16 |
#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE) |
| 17 |
#define __NEED_size_t |
| 18 |
#endif |
| 19 |
|
| 20 |
#include <bits/alltypes.h> |
| 21 |
|
| 22 |
#include <bits/dirent.h> |
| 23 |
|
| 24 |
#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ |
| 25 |
typedef struct __dirstream DIR; |
| 26 |
#else |
| 27 |
#include <__typedef_DIR.h> |
| 28 |
#endif |
| 29 |
|
| 30 |
#define d_fileno d_ino |
| 31 |
|
| 32 |
int closedir(DIR *); |
| 33 |
DIR *fdopendir(int); |
| 34 |
DIR *opendir(const char *); |
| 35 |
struct dirent *readdir(DIR *); |
| 36 |
#ifdef __wasilibc_unmodified_upstream /* readdir_r is obsolete */ |
| 37 |
int readdir_r(DIR *__restrict, struct dirent *__restrict, struct dirent **__restrict); |
| 38 |
#endif |
| 39 |
void rewinddir(DIR *); |
| 40 |
int dirfd(DIR *); |
| 41 |
|
| 42 |
int alphasort(const struct dirent **, const struct dirent **); |
| 43 |
int scandir(const char *, struct dirent ***, int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **)); |
| 44 |
|
| 45 |
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) |
| 46 |
void seekdir(DIR *, long); |
| 47 |
long telldir(DIR *); |
| 48 |
#endif |
| 49 |
|
| 50 |
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) |
| 51 |
#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ |
| 52 |
#define DT_UNKNOWN 0 |
| 53 |
#define DT_FIFO 1 |
| 54 |
#define DT_CHR 2 |
| 55 |
#define DT_DIR 4 |
| 56 |
#define DT_BLK 6 |
| 57 |
#define DT_REG 8 |
| 58 |
#define DT_LNK 10 |
| 59 |
#define DT_SOCK 12 |
| 60 |
#define DT_WHT 14 |
| 61 |
#define IFTODT(x) ((x)>>12 & 017) |
| 62 |
#define DTTOIF(x) ((x)<<12) |
| 63 |
#endif |
| 64 |
int getdents(int, struct dirent *, size_t); |
| 65 |
#endif |
| 66 |
|
| 67 |
#ifdef _GNU_SOURCE |
| 68 |
int versionsort(const struct dirent **, const struct dirent **); |
| 69 |
#endif |
| 70 |
|
| 71 |
#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) |
| 72 |
#define dirent64 dirent |
| 73 |
#define readdir64 readdir |
| 74 |
#ifdef __wasilibc_unmodified_upstream /* readdir_r is obsolete */ |
| 75 |
#define readdir64_r readdir_r |
| 76 |
#endif |
| 77 |
#define scandir64 scandir |
| 78 |
#define alphasort64 alphasort |
| 79 |
#define versionsort64 versionsort |
| 80 |
#define off64_t off_t |
| 81 |
#define ino64_t ino_t |
| 82 |
#define getdents64 getdents |
| 83 |
#endif |
| 84 |
|
| 85 |
#ifdef __cplusplus |
| 86 |
} |
| 87 |
#endif |
| 88 |
|
| 89 |
#endif |