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 12 #include <rtthread.h> 13 14 /* 15 * dirent.h - format of directory entries 16 * Ref: http://www.opengroup.org/onlinepubs/009695399/basedefs/dirent.h.html 17 */ 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 25 #define DT_UNKNOWN 0x00 26 #define DT_REG 0x01 27 #define DT_DIR 0x02 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 #ifndef 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 43 #ifndef HAVE_DIRENT_STRUCTURE 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[256]; /* The null-terminated file name */ 50 }; 51 #endif 52 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 int); 59 long telldir(DIR *); 60 61 #ifdef __cplusplus 62 } 63 #endif 64 65 #endif 66