dirent.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. int dirfd(DIR *);
  29. int alphasort(const struct dirent **, const struct dirent **);
  30. int scandir(const char *, struct dirent ***, int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **));
  31. #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
  32. void seekdir(DIR *, long);
  33. long telldir(DIR *);
  34. #endif
  35. #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
  36. #define DT_UNKNOWN 0
  37. #define DT_FIFO 1
  38. #define DT_CHR 2
  39. #define DT_DIR 4
  40. #define DT_BLK 6
  41. #define DT_REG 8
  42. #define DT_LNK 10
  43. #define DT_SOCK 12
  44. #define DT_WHT 14
  45. #define IFTODT(x) ((x)>>12 & 017)
  46. #define DTTOIF(x) ((x)<<12)
  47. int getdents(int, struct dirent *, size_t);
  48. #endif
  49. #ifdef _GNU_SOURCE
  50. int versionsort(const struct dirent **, const struct dirent **);
  51. #endif
  52. #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
  53. #define dirent64 dirent
  54. #define readdir64 readdir
  55. #define readdir64_r readdir_r
  56. #define scandir64 scandir
  57. #define alphasort64 alphasort
  58. #define versionsort64 versionsort
  59. #define off64_t off_t
  60. #define ino64_t ino_t
  61. #define getdents64 getdents
  62. #endif
  63. #ifdef __cplusplus
  64. }
  65. #endif
  66. #endif