1
0

dirent.h 1.7 KB

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