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

NAME

6       dirent.h - format of directory entries
7

SYNOPSIS

9       #include <dirent.h>
10

DESCRIPTION

12       The internal format of directories is unspecified.
13
14       The <dirent.h> header shall define the following type:
15
16       DIR    A type representing a directory stream.
17
18
19       It  shall also define the structure dirent which shall include the fol‐
20       lowing members:
21
22
23              ino_t  d_ino       File serial number.
24
25              char   d_name[]    Name of entry.
26
27       The type ino_t shall be defined as described in <sys/types.h> .
28
29       The character array d_name is of unspecified size, but  the  number  of
30       bytes preceding the terminating null byte shall not exceed {NAME_MAX}.
31
32       The following shall be declared as functions and may also be defined as
33       macros. Function prototypes shall be provided.
34
35
36              int            closedir(DIR *);
37              DIR           *opendir(const char *);
38              struct dirent *readdir(DIR *);
39
40              int            readdir_r(DIR *restrict, struct dirent *restrict,
41                                 struct dirent **restrict);
42
43              void           rewinddir(DIR *);
44
45              void           seekdir(DIR *, long);
46              long           telldir(DIR *);
47
48
49       The following sections are informative.
50

APPLICATION USAGE

52       None.
53

RATIONALE

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

FUTURE DIRECTIONS

85       None.
86

SEE ALSO

88       <sys/types.h>,  the  System  Interfaces volume of IEEE Std 1003.1-2001,
89       closedir(), opendir(), readdir(), readdir_r(), rewinddir(),  seekdir(),
90       telldir()
91
93       Portions  of  this text are reprinted and reproduced in electronic form
94       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
95       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
96       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
97       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
98       event of any discrepancy between this version and the original IEEE and
99       The  Open Group Standard, the original IEEE and The Open Group Standard
100       is the referee document. The original Standard can be  obtained  online
101       at http://www.opengroup.org/unix/online.html .
102
103
104
105IEEE/The Open Group                  2003                       <dirent.h>(0P)
Impressum