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