dirent.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 FT_DEVICE 4 /* device */
  25. #define FT_SYMLINK 5 /* symbol link */
  26. #define FT_NONLOCK 6 /* non lock */
  27. #define DT_UNKNOWN 0x00
  28. #define DT_FIFO 0x01
  29. #define DT_SYMLINK 0x03
  30. #define DT_DIR 0x04
  31. #define DT_REG 0x08
  32. #ifndef HAVE_DIR_STRUCTURE
  33. #define HAVE_DIR_STRUCTURE
  34. typedef struct
  35. {
  36. int fd; /* directory file */
  37. char buf[512];
  38. int num;
  39. int cur;
  40. }DIR;
  41. #endif
  42. #ifndef HAVE_DIRENT_STRUCTURE
  43. #define HAVE_DIRENT_STRUCTURE
  44. #define DIRENT_NAME_MAX 256
  45. struct dirent
  46. {
  47. rt_uint8_t d_type; /* The type of the file */
  48. rt_uint8_t d_namlen; /* The length of the not including the terminating null file name */
  49. rt_uint16_t d_reclen; /* length of this record */
  50. char d_name[DIRENT_NAME_MAX]; /* The null-terminated file name */
  51. };
  52. #endif
  53. int closedir(DIR *);
  54. DIR *opendir(const char *);
  55. struct dirent *readdir(DIR *);
  56. int readdir_r(DIR *, struct dirent *, struct dirent **);
  57. void rewinddir(DIR *);
  58. void seekdir(DIR *, long);
  59. long telldir(DIR *);
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63. #endif