1
0

dirent.h 1.5 KB

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