#ifndef _DIRENT_H #define _DIRENT_H #include #include /* An entry in a directory. */ struct dirent { ino_t d_ino; off_t d_off; unsigned short d_reclen; unsigned char d_type; char d_name[NAME_MAX]; }; #define DT_BLK 1 // This is a block device. #define DT_CHR 2 // This is a character device. #define DT_DIR 3 // This is a directory. #define DT_FIFO 4 // This is a named pipe (FIFO). #define DT_LNK 5 // This is a symbolic link. #define DT_REG 6 // This is a regular file. #define DT_SOCK 7 // This is a UNIX domain socket. #define DT_UNKNOWN 0 // The file type could not be determined. /* A stream representing a directory. */ typedef struct { int d_dirfd; } DIR; #ifdef __cplusplus extern "C" { #endif /* Opens the directory at path and returns a handle to it, or NULL on error. */ DIR* opendir(const char* path); /* Returns a new directory handle associated with the file descriptor fd. */ DIR* fdopendir(int fd); /* Closes the directory stream. */ int closedir(DIR* stream); /* Reads an entry from the directory stream. The contents of the pointer returned may be overwritten by subsequent * calls to readdir(). */ struct dirent* readdir(DIR* stream); /* Returns the file descriptor associated with stream. */ int dirfd(DIR* stream); /* Positions stream's offset at the start of the directory. */ void rewinddir(DIR* stream); /* Returns the current offset position for stream. */ long telldir(DIR* stream); /* Moves stream's read offset to offset, which should be the return value of a previous call to telldir(). */ void seekdir(DIR* stream, long offset); #ifdef __cplusplus } #endif #endif