This section describes what you find in a single directory entry, as you might obtain it from a directory stream. All the symbols are declared in the header file dirent.h.
This is a structure type used to return information about directory entries. It contains the following fields:
This is the null-terminated file name component. This is the only field you can count on in all POSIX systems.
This is the file serial number. For BSD compatibility, you can also
refer to this member as
d_ino. On GNU/Linux and GNU/Hurd systems and most POSIX
systems, for most files this the same as the
st_ino member that
stat will return for the file. See File Attributes.
unsigned char d_namlen
This is the length of the file name, not including the terminating
null character. Its type is
unsigned char because that is the
integer type of the appropriate size. This member is a BSD extension.
_DIRENT_HAVE_D_NAMLEN is defined if this member is
unsigned char d_type
This is the type of the file, possibly unknown. The following constants are defined for its value:
The type is unknown. Only some filesystems have full support to return the type of the file, others might always return this value.
A regular file.
A named pipe, or FIFO. See FIFO Special Files.
A local-domain socket.
A character device.
A block device.
A symbolic link.
This member is a BSD extension. The symbol
is defined if this member is available. On systems where it is used, it
corresponds to the file type bits in the
st_mode member of
struct stat. If the value cannot be determined the member
value is DT_UNKNOWN. These two macros convert between
Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.
This returns the
d_type value corresponding to mode.
This structure may contain additional members in the future. Their
availability is always announced in the compilation environment by a
_DIRENT_HAVE_D_xxx where xxx is replaced
by the name of the new member. For instance, the member
available on some systems is announced through the macro
When a file has multiple names, each name has its own directory entry.
The only way you can tell that the directory entries belong to a
single file is that they have the same value for the
File attributes such as size, modification times etc., are part of the file itself, not of any particular directory entry. See File Attributes.