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
int16_t d_reclen;
int16_t d_namelen;
char d_name[1];
};
struct dirent64 {
ino64_t d_ino;
off64_t d_offset;
_Int16t d_reclen;
_Int16t d_namelen;
char d_name[1];
};
BlackBerry 10.0.0
The dirent structure describes an entry in a directory. The members include:
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
dirent is POSIX 1003.1; dirent64 is Large-file support