From 3a0a3f7c695d7b471ff1763f5eefa02032dda1e9 Mon Sep 17 00:00:00 2001 From: armink Date: Wed, 2 May 2018 15:18:55 +0800 Subject: [PATCH] [Components/dlib] Add dirent.h to dlib libc. --- components/libc/compilers/dlib/dirent.h | 54 +++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 components/libc/compilers/dlib/dirent.h diff --git a/components/libc/compilers/dlib/dirent.h b/components/libc/compilers/dlib/dirent.h new file mode 100644 index 0000000000..61e77b9767 --- /dev/null +++ b/components/libc/compilers/dlib/dirent.h @@ -0,0 +1,54 @@ +#ifndef __RTT_DIRENT_H__ +#define __RTT_DIRENT_H__ + +#include +#include + +/* +* dirent.h - format of directory entries + * Ref: http://www.opengroup.org/onlinepubs/009695399/basedefs/dirent.h.html + */ + +/* File types */ +#define FT_REGULAR 0 /* regular file */ +#define FT_SOCKET 1 /* socket file */ +#define FT_DIRECTORY 2 /* directory */ +#define FT_USER 3 /* user defined */ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef HAVE_DIR_STRUCTURE +typedef struct +{ + int fd; /* directory file */ + char buf[512]; + int num; + int cur; +} DIR; +#endif + +#ifndef HAVE_DIRENT_STRUCTURE +struct dirent +{ + rt_uint8_t d_type; /* The type of the file */ + rt_uint8_t d_namlen; /* The length of the not including the terminating null file name */ + rt_uint16_t d_reclen; /* length of this record */ + char d_name[256]; /* The null-terminated file name */ +}; +#endif + +int closedir(DIR *); +DIR *opendir(const char *); +struct dirent *readdir(DIR *); +int readdir_r(DIR *, struct dirent *, struct dirent **); +void rewinddir(DIR *); +void seekdir(DIR *, long int); +long telldir(DIR *); + +#ifdef __cplusplus +} +#endif + +#endif