xref: /nrf52832-nimble/rt-thread/components/libc/compilers/dlib/dirent.h (revision 104654410c56c573564690304ae786df310c91fc)
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 #include <rtlibc.h>
14 
15 /*
16 * dirent.h - format of directory entries
17  * Ref: http://www.opengroup.org/onlinepubs/009695399/basedefs/dirent.h.html
18  */
19 
20 /* File types */
21 #define FT_REGULAR      0   /* regular file */
22 #define FT_SOCKET       1   /* socket file  */
23 #define FT_DIRECTORY    2   /* directory    */
24 #define FT_USER         3   /* user defined */
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #ifndef HAVE_DIR_STRUCTURE
31 typedef struct
32 {
33     int fd;                         /* directory file */
34     char buf[512];
35     int num;
36     int cur;
37 } DIR;
38 #endif
39 
40 #ifndef HAVE_DIRENT_STRUCTURE
41 struct dirent
42 {
43     rt_uint8_t  d_type;             /* The type of the file */
44     rt_uint8_t  d_namlen;           /* The length of the not including the terminating null file name */
45     rt_uint16_t d_reclen;           /* length of this record */
46     char d_name[256];               /* The null-terminated file name */
47 };
48 #endif
49 
50 int            closedir(DIR *);
51 DIR           *opendir(const char *);
52 struct dirent *readdir(DIR *);
53 int            readdir_r(DIR *, struct dirent *, struct dirent **);
54 void           rewinddir(DIR *);
55 void           seekdir(DIR *, long int);
56 long           telldir(DIR *);
57 
58 #ifdef __cplusplus
59 }
60 #endif
61 
62 #endif
63