|
|
1.1 root 1: ..From teklabs!ogcvax!root Tue Aug 3 05:14:38 1982
2: ..TH DIRECTORY 3 "OGC Revision 8/02/82"
3: .TH DIRECTORY 3X 8/1/82
4: .UC 4.1b Compatability
5: .SH NAME
6: opendir, readdir, telldir, seekdir, rewinddir, closedir \- flexible length directory operations
7: .SH SYNOPSIS
8: .B #include <dir.h>
9: .PP
10: .SM
11: .B DIR
12: .B *opendir(filename)
13: .br
14: .B char *filename;
15: .PP
16: .SM
17: .B struct direct
18: .B *readdir(dirp)
19: .br
20: .B DIR *dirp;
21: .PP
22: .SM
23: .B long
24: .B telldir(dirp)
25: .br
26: .B DIR *dirp;
27: .PP
28: .SM
29: .B seekdir(dirp, loc)
30: .br
31: .B DIR *dirp;
32: .br
33: .B long loc;
34: .PP
35: .SM
36: .B rewinddir(dirp)
37: .br
38: .B DIR *dirp;
39: .PP
40: .SM
41: .B closedir(dirp)
42: .br
43: .B DIR *dirp;
44: .PP
45: .SM
46: .B cc ... -lndir
47: .SH DESCRIPTION
48: The purpose of this library is to simulate
49: the new flexible length directory names of 4.2bsd Unix
50: on top of the old directory structure of 4.1bsd.
51: It allows programs to be converted immediately
52: to the new directory access interface,
53: so that they need only be relinked
54: when 4.2bsd becomes available.
55: .PP
56: .I opendir
57: opens the directory named by
58: .I filename
59: and associates a
60: .I directory stream
61: with it.
62: .I opendir
63: returns a pointer to be used to identify the
64: .I directory stream
65: in subsequent operations.
66: The pointer
67: .SM
68: .B NULL
69: is returned if
70: .I filename
71: cannot be accessed or is not a directory.
72: .PP
73: .I readdir
74: returns a pointer to the next directory entry.
75: It returns
76: .B NULL
77: upon reaching the end of the directory or detecting
78: an invalid
79: .I seekdir
80: operation.
81: .PP
82: .I telldir
83: returns the current location associated with the named
84: .I directory stream.
85: .PP
86: .I seekdir
87: sets the position of the next
88: .I readdir
89: operation on the
90: .I directory stream.
91: The new position reverts to the one associated with the
92: .I directory stream
93: when the
94: .I telldir
95: operation was performed.
96: Values returned by
97: .I telldir
98: are good only for the lifetime of the DIR pointer from
99: which they are derived.
100: If the directory is closed and then reopened,
101: the
102: .I telldir
103: value may be invalidated
104: due to undetected directory compaction.
105: It is safe to use a previous
106: .I telldir
107: value immediately after a call to
108: .I opendir
109: and before any calls to
110: .I readdir.
111: .PP
112: .I rewinddir
113: resets the position of the named
114: .I directory stream
115: to the beginning of the directory.
116: .PP
117: .I closedir
118: causes the named
119: .I directory stream
120: to be closed,
121: and the structure associated with the DIR pointer to be freed.
122: .PP
123: See /usr/include/dir.h for a description of the fields available in
124: a directory entry.
125: The preferred way to search the current directory for entry "name" is:
126: .br
127: .sp
128: len = strlen(name);
129: .br
130: dirp = opendir(".");
131: .br
132: for (dp = readdir(dirp); dp != NULL; dp = readdir(dir))
133: .br
134: if (dp->d_namlen == len && !strcmp(dp->d_name, name)) {
135: .br
136: closedir(dirp);
137: .br
138: return FOUND;
139: .br
140: }
141: .br
142: closedir(dirp);
143: .br
144: return NOT_FOUND;
145: .SH LINKING
146: This library is accessed by specifying "-lndir" as the
147: last argument to the compile line, e.g.:
148: .br
149: .sp
150: cc -o prog prog.c -lndir
151: .SH "SEE ALSO"
152: /usr/include/dir.h,
153: open(2),
154: close(2),
155: read(2),
156: lseek(2)
157: .SH AUTHOR
158: Kirk McKusick.
159: Report problems to mckusick@berkeley or ucbvax!mckusick.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.