1
0

dirent.h 1.6 KB

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