dirent.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 __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. int getdents(int, struct dirent *, size_t);
  47. #endif
  48. #ifdef _GNU_SOURCE
  49. int versionsort(const struct dirent **, const struct dirent **);
  50. #endif
  51. #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
  52. #define dirent64 dirent
  53. #define readdir64 readdir
  54. #define readdir64_r readdir_r
  55. #define scandir64 scandir
  56. #define alphasort64 alphasort
  57. #define versionsort64 versionsort
  58. #define off64_t off_t
  59. #define ino64_t ino_t
  60. #define getdents64 getdents
  61. #endif
  62. #ifdef __cplusplus
  63. }
  64. #endif
  65. #endif