dirent.h 1.4 KB

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