dirent.h 1.7 KB

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