dirent.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef _DIRENT_H
  2. #define _DIRENT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #if __STDC_VERSION__ >= 199901L
  7. #define __restrict restrict
  8. #elif !defined(__GNUC__)
  9. #define __restrict
  10. #endif
  11. #define __NEED_ino_t
  12. #define __NEED_off_t
  13. #ifdef _BSD_SOURCE
  14. #define __NEED_size_t
  15. #endif
  16. #include <bits/alltypes.h>
  17. typedef struct __DIR_s DIR;
  18. struct dirent
  19. {
  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. #define d_fileno d_ino
  27. int closedir(DIR *);
  28. DIR *fdopendir(int);
  29. DIR *opendir(const char *);
  30. struct dirent *readdir(DIR *);
  31. int readdir_r(DIR *__restrict, struct dirent *__restrict, struct dirent **__restrict);
  32. void rewinddir(DIR *);
  33. void seekdir(DIR *, long);
  34. long telldir(DIR *);
  35. int dirfd(DIR *);
  36. int alphasort(const struct dirent **, const struct dirent **);
  37. int scandir(const char *, struct dirent ***, int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **));
  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. #endif
  51. #ifdef _GNU_SOURCE
  52. int versionsort(const struct dirent **, const struct dirent **);
  53. #endif
  54. #ifdef _BSD_SOURCE
  55. int getdents(int, struct dirent *, size_t);
  56. #endif
  57. #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
  58. #define dirent64 dirent
  59. #define readdir64 readdir
  60. #define readdir64_r readdir_r
  61. #define scandir64 scandir
  62. #define alphasort64 alphasort
  63. #define versionsort64 versionsort
  64. #define off64_t off_t
  65. #define ino64_t ino_t
  66. #ifdef _BSD_SOURCE
  67. #define getdents64 getdents
  68. #endif
  69. #endif
  70. #ifdef __cplusplus
  71. }
  72. #endif
  73. #endif