dirent.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef _DIRENT_H
  2. #define _DIRENT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #define __NEED_ino_t
  7. #define __NEED_off_t
  8. #include <bits/alltypes.h>
  9. typedef struct __DIR_s DIR;
  10. struct dirent
  11. {
  12. ino_t d_ino;
  13. off_t d_off;
  14. unsigned short d_reclen;
  15. unsigned char d_type;
  16. char d_name[256];
  17. };
  18. #define d_fileno d_ino
  19. int closedir(DIR *);
  20. DIR *fdopendir(int);
  21. DIR *opendir(const char *);
  22. struct dirent *readdir(DIR *);
  23. int readdir_r(DIR *, struct dirent *, struct dirent **);
  24. void rewinddir(DIR *);
  25. void seekdir(DIR *, long);
  26. long telldir(DIR *);
  27. int dirfd(DIR *);
  28. int alphasort(const struct dirent **, const struct dirent **);
  29. int scandir(const char *, struct dirent ***, int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **));
  30. #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
  31. #define DT_UNKNOWN 0
  32. #define DT_FIFO 1
  33. #define DT_CHR 2
  34. #define DT_DIR 4
  35. #define DT_BLK 6
  36. #define DT_REG 8
  37. #define DT_LNK 10
  38. #define DT_SOCK 12
  39. #define DT_WHT 14
  40. #define IFTODT(x) ((x)>>12 & 017)
  41. #define DTTOIF(x) ((x)<<12)
  42. #endif
  43. #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
  44. #define dirent64 dirent
  45. #define readdir64 readdir
  46. #define readdir64_r readdir_r
  47. #define scandir64 scandir
  48. #define alphasort64 alphasort
  49. #define off64_t off_t
  50. #define ino64_t ino_t
  51. #endif
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif