![]() |
![]() |
![]() |
![]() |
![]() |
This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. |
Data structure for a directory entry
#include <dirent.h> struct dirent { #if _FILE_OFFSET_BITS - 0 == 64 ino_t d_ino; /* File serial number. */ off_t d_offset; #elif !defined(_FILE_OFFSET_BITS) || _FILE_OFFSET_BITS == 32 #if defined(__LITTLEENDIAN__) ino_t d_ino; /* File serial number. */ ino_t d_ino_hi; off_t d_offset; off_t d_offset_hi; #elif defined(__BIGENDIAN__) ino_t d_ino_hi; ino_t d_ino; /* File serial number. */ off_t d_offset_hi; off_t d_offset; #else #error endian not configured for system #endif #else #error _FILE_OFFSET_BITS value is unsupported #endif _Int16t d_reclen; _Int16t d_namelen; char d_name[1]; };
The dirent structure describes an entry in a directory. The members include:
![]() |
The struct dirent structure doesn't include space
for the pathname.
If you create an instance of this structure, you must provide space for
the name:
struct dirent *entry; entry = malloc( offsetof(struct dirent, d_name) + NAME_MAX + 1 ); or: struct { struct dirent ent; char namebuf[NAME_MAX + 1 + offsetof(struct dirent, d_name) - sizeof( struct dirent)]; } entry |
readdir(), readdir_r(), scandir()
![]() |
![]() |
![]() |
![]() |