1dirent.h(0P)               POSIX Programmer's Manual              dirent.h(0P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       dirent.h — format of directory entries
14

SYNOPSIS

16       #include <dirent.h>
17

DESCRIPTION

19       The internal format of directories is unspecified.
20
21       The <dirent.h> header shall define the following type:
22
23       DIR     A type representing a directory stream. The DIR type may be  an
24               incomplete type.
25
26       It  shall also define the structure dirent which shall include the fol‐
27       lowing members:
28
29           ino_t  d_ino       File serial number.
30           char   d_name[]    Filename string of entry.
31
32       The <dirent.h> header shall define  the  ino_t  type  as  described  in
33       <sys/types.h>.
34
35       The  array  d_name is of unspecified size, but shall contain a filename
36       of at most {NAME_MAX} bytes followed by a terminating null byte.
37
38       The following shall be declared as functions and may also be defined as
39       macros. Function prototypes shall be provided.
40
41           int            alphasort(const struct dirent **, const struct dirent **);
42           int            closedir(DIR *);
43           int            dirfd(DIR *);
44           DIR           *fdopendir(int);
45           DIR           *opendir(const char *);
46           struct dirent *readdir(DIR *);
47           int            readdir_r(DIR *restrict, struct dirent *restrict,
48                              struct dirent **restrict);
49           void           rewinddir(DIR *);
50           int            scandir(const char *, struct dirent ***,
51                              int (*)(const struct dirent *),
52                              int (*)(const struct dirent **,
53                              const struct dirent **));
54           void           seekdir(DIR *, long);
55           long           telldir(DIR *);
56
57       The following sections are informative.
58

APPLICATION USAGE

60       None.
61

RATIONALE

63       Information  similar to that in the <dirent.h> header is contained in a
64       file <sys/dir.h> in 4.2 BSD and 4.3 BSD. The equivalent in these imple‐
65       mentations  of struct dirent from this volume of POSIX.1‐2008 is struct
66       direct.  The filename was changed because the name <sys/dir.h> was also
67       used  in earlier implementations to refer to definitions related to the
68       older access method; this produced name  conflicts.  The  name  of  the
69       structure was changed because this volume of POSIX.1‐2008 does not com‐
70       pletely define what is in the structure, so it could  be  different  on
71       some implementations from struct direct.
72
73       The  name of an array of char of an unspecified size should not be used
74       as an lvalue. Use of:
75
76           sizeof(d_name)
77
78       is incorrect; use:
79
80           strlen(d_name)
81
82       instead.
83
84       The array of char d_name is not a fixed size. Implementations may  need
85       to  declare  struct  dirent with an array size for d_name of 1, but the
86       actual number of bytes provided matches (or only slightly exceeds)  the
87       length of the filename string.
88

FUTURE DIRECTIONS

90       None.
91

SEE ALSO

93       <sys_types.h>
94
95       The  System Interfaces volume of POSIX.1‐2008, alphasort(), closedir(),
96       dirfd(), fdopendir(), readdir(), rewinddir(), seekdir(), telldir()
97
99       Portions of this text are reprinted and reproduced in  electronic  form
100       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
101       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
102       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
103       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
104       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
105       event of any discrepancy between this version and the original IEEE and
106       The  Open Group Standard, the original IEEE and The Open Group Standard
107       is the referee document. The original Standard can be  obtained  online
108       at http://www.unix.org/online.html .
109
110       Any  typographical  or  formatting  errors that appear in this page are
111       most likely to have been introduced during the conversion of the source
112       files  to  man page format. To report such errors, see https://www.ker
113       nel.org/doc/man-pages/reporting_bugs.html .
114
115
116
117IEEE/The Open Group                  2013                         dirent.h(0P)
Impressum