dirent.h 1.3 KB

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