|
Lines 47-53
Link Here
|
| 47 |
.In sys/types.h |
47 |
.In sys/types.h |
| 48 |
.In dirent.h |
48 |
.In dirent.h |
| 49 |
.Ft DIR * |
49 |
.Ft DIR * |
| 50 |
.Fn opendir "const char *filename" |
50 |
.Fn opendir "const char *dirname" |
| 51 |
.Ft struct dirent * |
51 |
.Ft struct dirent * |
| 52 |
.Fn readdir "DIR *dirp" |
52 |
.Fn readdir "DIR *dirp" |
| 53 |
.Ft int |
53 |
.Ft int |
|
Lines 67-73
Link Here
|
| 67 |
.Fn opendir |
67 |
.Fn opendir |
| 68 |
function |
68 |
function |
| 69 |
opens the directory named by |
69 |
opens the directory named by |
| 70 |
.Fa filename , |
70 |
.Fa dirname , |
| 71 |
associates a |
71 |
associates a |
| 72 |
.Em directory stream |
72 |
.Em directory stream |
| 73 |
with it |
73 |
with it |
|
Lines 75-87
Link Here
|
| 75 |
returns a pointer to be used to identify the |
75 |
returns a pointer to be used to identify the |
| 76 |
.Em directory stream |
76 |
.Em directory stream |
| 77 |
in subsequent operations. |
77 |
in subsequent operations. |
| 78 |
The pointer |
|
|
| 79 |
.Dv NULL |
| 80 |
is returned if |
| 81 |
.Fa filename |
| 82 |
cannot be accessed, or if it cannot |
| 83 |
.Xr malloc 3 |
| 84 |
enough memory to hold the whole thing. |
| 85 |
.Pp |
78 |
.Pp |
| 86 |
The |
79 |
The |
| 87 |
.Fn readdir |
80 |
.Fn readdir |
|
Lines 184-195
Link Here
|
| 184 |
(void)closedir(dirp); |
177 |
(void)closedir(dirp); |
| 185 |
return NOT_FOUND; |
178 |
return NOT_FOUND; |
| 186 |
.Ed |
179 |
.Ed |
|
|
180 |
.Sh RETURN VALUES |
| 181 |
Upon successful completion, |
| 182 |
.Fn opendir |
| 183 |
shall return a pointer to an object of type DIR. |
| 184 |
Otherwise, a null pointer shall be returned and |
| 185 |
.Va errno |
| 186 |
set to indicate the error. |
| 187 |
.Sh ERRORS |
| 188 |
The |
| 189 |
.Fn opendir |
| 190 |
function shall fail if: |
| 191 |
.Bl -tag -width Er |
| 192 |
.It Bq Er EACCESS |
| 193 |
Search permission is denied for the component of the path prefix of |
| 194 |
.Fa dirname |
| 195 |
or read permission is denied for |
| 196 |
.Fa dirname . |
| 197 |
.It Bq Er ELOOP |
| 198 |
A loop exists in symbolic links encountered during resolution of the |
| 199 |
.Fa dirname |
| 200 |
argument. |
| 201 |
.It Bq Er ENAMETOOLONG |
| 202 |
The length of the |
| 203 |
.Fa dirname |
| 204 |
argument exceeds |
| 205 |
.Brq Dv PATH_MAX |
| 206 |
or |
| 207 |
a pathname component is longer than |
| 208 |
.Brq Dv NAME_MAX . |
| 209 |
.It Bq Er ENOENT |
| 210 |
A component of |
| 211 |
.Fa dirname |
| 212 |
does not name an existing directory or |
| 213 |
.Fa dirname |
| 214 |
is an empty string. |
| 215 |
.It Bq Er ENOTDIR |
| 216 |
A component of |
| 217 |
.Fa dirname |
| 218 |
is not a directory. |
| 187 |
.Sh SEE ALSO |
219 |
.Sh SEE ALSO |
| 188 |
.Xr close 2 , |
220 |
.Xr close 2 , |
| 189 |
.Xr lseek 2 , |
221 |
.Xr lseek 2 , |
| 190 |
.Xr open 2 , |
222 |
.Xr open 2 , |
| 191 |
.Xr read 2 , |
223 |
.Xr read 2 , |
| 192 |
.Xr dir 5 |
224 |
.Xr dir 5 |
|
|
225 |
.Sh STANDARDS |
| 226 |
The function |
| 227 |
.Fn opendir |
| 228 |
is believed to conform to |
| 229 |
.St -p1003.1-2004 . |
| 193 |
.Sh HISTORY |
230 |
.Sh HISTORY |
| 194 |
The |
231 |
The |
| 195 |
.Fn opendir , |
232 |
.Fn opendir , |