dirent.h 1.7 KB

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