rt-thread/components/libc/compilers/common/include/dirent.h

76 lines
1.7 KiB
C
Raw Normal View History

2018-10-14 19:28:18 +08:00
/*
* Copyright (c) 2006-2022, RT-Thread Development Team
2018-10-14 19:28:18 +08:00
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
*/
2021-08-31 10:27:09 +08:00
#ifndef __DIRENT_H__
#define __DIRENT_H__
2013-01-08 22:40:58 +08:00
2021-08-31 10:27:09 +08:00
#include <rtdef.h>
#ifdef __cplusplus
extern "C" {
#endif
2013-01-08 22:40:58 +08:00
/*
* dirent.h - format of directory entries
* Ref: http://www.opengroup.org/onlinepubs/009695399/basedefs/dirent.h.html
*/
/* File types */
2021-03-08 18:19:04 +08:00
#define FT_REGULAR 0 /* regular file */
#define FT_SOCKET 1 /* socket file */
#define FT_DIRECTORY 2 /* directory */
#define FT_USER 3 /* user defined */
2023-06-10 21:35:25 +08:00
#define FT_DEVICE 4 /* device */
#define FT_SYMLINK 5 /* symbol link */
2013-01-08 22:40:58 +08:00
2021-03-08 18:19:04 +08:00
#define DT_UNKNOWN 0x00
2023-06-10 21:35:25 +08:00
#define DT_FIFO 0x01
#define DT_SYMLINK 0x03
#define DT_DIR 0x04
#define DT_REG 0x08
2013-01-08 22:40:58 +08:00
#ifndef HAVE_DIR_STRUCTURE
2021-08-31 10:27:09 +08:00
#define HAVE_DIR_STRUCTURE
2021-03-08 18:19:04 +08:00
typedef struct
2013-01-08 22:40:58 +08:00
{
2021-03-08 18:19:04 +08:00
int fd; /* directory file */
char buf[512];
int num;
int cur;
2021-08-31 10:27:09 +08:00
}DIR;
2013-01-08 22:40:58 +08:00
#endif
#ifndef HAVE_DIRENT_STRUCTURE
2021-08-31 10:27:09 +08:00
#define HAVE_DIRENT_STRUCTURE
#define DIRENT_NAME_MAX 256
2013-01-08 22:40:58 +08:00
struct dirent
{
2021-03-08 18:19:04 +08:00
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 */
2021-08-31 10:27:09 +08:00
char d_name[DIRENT_NAME_MAX]; /* The null-terminated file name */
2013-01-08 22:40:58 +08:00
};
#endif
int closedir(DIR *);
DIR *opendir(const char *);
struct dirent *readdir(DIR *);
int readdir_r(DIR *, struct dirent *, struct dirent **);
void rewinddir(DIR *);
2023-06-10 21:35:25 +08:00
void seekdir(DIR *, long);
2013-01-08 22:40:58 +08:00
long telldir(DIR *);
#ifdef __cplusplus
}
#endif
#endif