1 #pragma once 2 3 #ifdef __cplusplus 4 extern "C" { 5 #endif 6 7 #include <features.h> 8 9 #define __NEED_ino_t 10 #define __NEED_off_t 11 #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE) 12 #define __NEED_size_t 13 #endif 14 15 #include <bits/alltypes.h> 16 17 typedef struct __dirstream DIR; 18 19 struct dirent { 20 ino_t d_ino; 21 off_t d_off; 22 unsigned short d_reclen; 23 unsigned char d_type; 24 char d_name[256]; 25 }; 26 27 #define d_fileno d_ino 28 29 int closedir(DIR*); 30 DIR* fdopendir(int); 31 DIR* opendir(const char*); 32 struct dirent* readdir(DIR*); 33 int readdir_r(DIR* __restrict, struct dirent* __restrict, struct dirent** __restrict); 34 void rewinddir(DIR*); 35 void seekdir(DIR*, long); 36 long telldir(DIR*); 37 int dirfd(DIR*); 38 39 int alphasort(const struct dirent**, const struct dirent**); 40 int scandir(const char*, struct dirent***, int (*)(const struct dirent*), 41 int (*)(const struct dirent**, const struct dirent**)); 42 43 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 44 #define DT_UNKNOWN 0 45 #define DT_FIFO 1 46 #define DT_CHR 2 47 #define DT_DIR 4 48 #define DT_BLK 6 49 #define DT_REG 8 50 #define DT_LNK 10 51 #define DT_SOCK 12 52 #define DT_WHT 14 53 #define IFTODT(x) ((x) >> 12 & 017) 54 #define DTTOIF(x) ((x) << 12) 55 int getdents(int, struct dirent*, size_t); 56 #endif 57 58 #ifdef _GNU_SOURCE 59 int versionsort(const struct dirent**, const struct dirent**); 60 #endif 61 62 #ifdef __cplusplus 63 } 64 #endif 65