master
 1#ifndef __wasilibc___header_dirent_h
 2#define __wasilibc___header_dirent_h
 3
 4#include <wasi/api.h>
 5
 6#define DT_BLK __WASI_FILETYPE_BLOCK_DEVICE
 7#define DT_CHR __WASI_FILETYPE_CHARACTER_DEVICE
 8#define DT_DIR __WASI_FILETYPE_DIRECTORY
 9#define DT_FIFO __WASI_FILETYPE_SOCKET_STREAM
10#define DT_LNK __WASI_FILETYPE_SYMBOLIC_LINK
11#define DT_REG __WASI_FILETYPE_REGULAR_FILE
12#define DT_UNKNOWN __WASI_FILETYPE_UNKNOWN
13
14// DT_SOCK is not supported in WASI Preview 1 (but will be in Preview 2).  We
15// define it regardless so that libc++'s `<filesystem>` implementation builds.
16// The exact value is mostly arbitrary, but chosen so it doesn't conflict with
17// any of the existing `__WASI_FILETYPE_*` flags.  We do not expect any new
18// flags to be added to WASI Preview 1, so that should be sufficient.
19#define DT_SOCK 20
20
21#define IFTODT(x) (__wasilibc_iftodt(x))
22#define DTTOIF(x) (__wasilibc_dttoif(x))
23
24#include <__struct_dirent.h>
25#include <__typedef_DIR.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31int __wasilibc_iftodt(int x);
32int __wasilibc_dttoif(int x);
33
34int closedir(DIR *);
35DIR *opendir(const char *);
36DIR *fdopendir(int);
37int fdclosedir(DIR *);
38struct dirent *readdir(DIR *);
39void rewinddir(DIR *);
40void seekdir(DIR *, long);
41long telldir(DIR *);
42DIR *opendirat(int, const char *);
43void rewinddir(DIR *);
44int scandirat(int, const char *, struct dirent ***,
45              int (*)(const struct dirent *),
46              int (*)(const struct dirent **, const struct dirent **));
47
48#ifdef __cplusplus
49}
50#endif
51
52#endif