2
0

dirent.h 1.9 KB

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