summaryrefslogtreecommitdiffstats
path: root/man0p/dirent.h.0p
blob: 9cfa5a4ccf582b0ebbf2627f40f160c37d7717c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
.TH "<dirent.h>" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" <dirent.h> 
.SH NAME
dirent.h \- format of directory entries
.SH SYNOPSIS
.LP
\fB#include <dirent.h>\fP
.SH DESCRIPTION
.LP
The internal format of directories is unspecified.
.LP
The \fI<dirent.h>\fP header shall define the following type:
.TP 7
\fBDIR\fP
A type representing a directory stream.
.sp
.LP
It shall also define the structure \fBdirent\fP which shall include
the following members:
.sp
.RS
.nf

\fB
ino_t  d_ino      \fP File serial number. \fB

char   d_name[]   \fP Name of entry. \fB
\fP
.fi
.RE
.LP
The type \fBino_t\fP shall be defined as described in \fI<sys/types.h>\fP
\&. 
.LP
The character array \fId_name\fP is of unspecified size, but the number
of bytes preceding the terminating null byte shall not
exceed {NAME_MAX}.
.LP
The following shall be declared as functions and may also be defined
as macros. Function prototypes shall be provided.
.sp
.RS
.nf

\fBint            closedir(DIR *);
DIR           *opendir(const char *);
struct dirent *readdir(DIR *);

int            readdir_r(DIR *restrict, struct dirent *restrict,
                   struct dirent **restrict);

void           rewinddir(DIR *);

void           seekdir(DIR *, long);
long           telldir(DIR *);

\fP
.fi
.RE
.LP
\fIThe following sections are informative.\fP
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
Information similar to that in the \fI<dirent.h>\fP header is contained
in a file \fI<sys/dir.h>\fP in 4.2 BSD and
4.3 BSD. The equivalent in these implementations of \fBstruct dirent\fP
from this volume of IEEE\ Std\ 1003.1-2001 is
\fBstruct direct\fP. The filename was changed because the name \fI<sys/dir.h>\fP
was also used in earlier implementations
to refer to definitions related to the older access method; this produced
name conflicts. The name of the structure was changed
because this volume of IEEE\ Std\ 1003.1-2001 does not completely
define what is in the structure, so it could be different
on some implementations from \fBstruct direct\fP.
.LP
The name of an array of \fBchar\fP of an unspecified size should not
be used as an lvalue. Use of:
.sp
.RS
.nf

\fBsizeof(d_name)
\fP
.fi
.RE
.LP
is incorrect; use:
.sp
.RS
.nf

\fBstrlen(d_name)
\fP
.fi
.RE
.LP
instead.
.LP
The array of \fBchar\fP \fId_name\fP is not a fixed size. Implementations
may need to declare \fBstruct dirent\fP with an
array size for \fId_name\fP of 1, but the actual number of characters
provided matches (or only slightly exceeds) the length of
the filename.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fI<sys/types.h>\fP , the System Interfaces volume of IEEE\ Std\ 1003.1-2001,
\fIclosedir\fP(), \fIopendir\fP(), \fIreaddir\fP(), \fIreaddir_r\fP(),
\fIrewinddir\fP(), \fIseekdir\fP(), \fItelldir\fP()
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .