dirent.h 1.8 KB

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