dirent.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef __RTT_DIRENT_H__
  2. #define __RTT_DIRENT_H__
  3. #include <rtthread.h>
  4. /*
  5. * dirent.h - format of directory entries
  6. * Ref: http://www.opengroup.org/onlinepubs/009695399/basedefs/dirent.h.html
  7. */
  8. /* File types */
  9. #define FT_REGULAR 0 /* regular file */
  10. #define FT_SOCKET 1 /* socket file */
  11. #define FT_DIRECTORY 2 /* directory */
  12. #define FT_USER 3 /* user defined */
  13. #define DT_UNKNOWN 0x00
  14. #define DT_REG 0x01
  15. #define DT_DIR 0x02
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. #ifndef HAVE_DIR_STRUCTURE
  20. typedef struct
  21. {
  22. int fd; /* directory file */
  23. char buf[512];
  24. int num;
  25. int cur;
  26. } DIR;
  27. #endif
  28. #ifndef HAVE_DIRENT_STRUCTURE
  29. struct dirent
  30. {
  31. rt_uint8_t d_type; /* The type of the file */
  32. rt_uint8_t d_namlen; /* The length of the not including the terminating null file name */
  33. rt_uint16_t d_reclen; /* length of this record */
  34. char d_name[256]; /* The null-terminated file name */
  35. };
  36. #endif
  37. int closedir(DIR *);
  38. DIR *opendir(const char *);
  39. struct dirent *readdir(DIR *);
  40. int readdir_r(DIR *, struct dirent *, struct dirent **);
  41. void rewinddir(DIR *);
  42. void seekdir(DIR *, long int);
  43. long telldir(DIR *);
  44. #ifdef __cplusplus
  45. }
  46. #endif
  47. #endif