dirent.h 1.9 KB

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