2021-12-21 18:47:01 +01:00
|
|
|
#ifndef __DIRENT_H__
|
|
|
|
# define __DIRENT_H__
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <bits/types/DIR.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#define DT_UNKNOWN 0 /* Unknown type */
|
2021-12-23 23:50:48 +01:00
|
|
|
#define DT_BLK 1 /* Block device */
|
|
|
|
#define DT_CHR 2 /* Character device */
|
|
|
|
#define DT_DIR 3 /* Directory */
|
|
|
|
#define DT_FIFO 4 /* FIFO */
|
|
|
|
#define DT_LNK 5 /* Symbolic link */
|
|
|
|
#define DT_REG 6 /* Regular file */
|
|
|
|
#define DT_SOCK 7 /* Socket */
|
2021-12-21 18:47:01 +01:00
|
|
|
|
|
|
|
/* In gint d_ino is unused; but it's required by POSIX.1. */
|
|
|
|
struct dirent {
|
|
|
|
/* Inode number */
|
|
|
|
ino_t d_ino;
|
|
|
|
/* Type, to avoid doing an additional stat() on the file */
|
|
|
|
unsigned char d_type;
|
|
|
|
/* NUL-terminated file name */
|
|
|
|
char d_name[];
|
|
|
|
};
|
|
|
|
|
|
|
|
/* The underlying syscall to access directory entries is getdents(2). But it
|
|
|
|
has no unified interface and no glibc wrapper on Linux; it's basically
|
|
|
|
hidden. So we define the API directly at the level of readdir(3). gint does
|
|
|
|
not implement any lower-level interface and directly associates a DIR * with
|
|
|
|
a directory file descriptor. */
|
|
|
|
|
|
|
|
/* Open a directory to inspect its contents. */
|
|
|
|
extern DIR *opendir(const char *__name);
|
|
|
|
|
|
|
|
/* Get the directory file descriptory associated with __dp. */
|
|
|
|
extern int dirfd(DIR *__dp);
|
|
|
|
|
|
|
|
/* Open a directory file descriptor to use as a directory stream. */
|
|
|
|
extern DIR *fdopendir(int __fd);
|
|
|
|
|
|
|
|
/* Read an entry from an open directory. */
|
|
|
|
extern struct dirent *readdir(DIR *__dp);
|
|
|
|
|
|
|
|
/* Get the current position within the directory. The particular value should
|
|
|
|
not be interpreted; it is just suitable to use in seekdir(). */
|
|
|
|
extern long telldir(DIR *__dp);
|
|
|
|
|
|
|
|
/* Seek into the directory; __pos should have been returned by telldir(). */
|
|
|
|
extern void seekdir(DIR *__dp, long __pos);
|
|
|
|
|
|
|
|
/* Rewind a directory to its start. */
|
|
|
|
extern void rewinddir(DIR *__dp);
|
|
|
|
|
|
|
|
/* Close an open directory. */
|
|
|
|
extern int closedir(DIR *__dp);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /*__DIRENT_H__*/
|