📄 directory.3s
字号:
..From teklabs!ogcvax!root Tue Aug 3 05:14:38 1982..TH DIRECTORY 3 "OGC Revision 8/02/82".TH DIRECTORY 3X 8/1/82.UC 4.1b Compatability.SH NAMEopendir, readdir, telldir, seekdir, rewinddir, closedir \- flexible length directory operations.SH SYNOPSIS.B #include <dir.h>.PP.SM.B DIR.B *opendir(filename).br.B char *filename;.PP.SM.B struct direct.B *readdir(dirp).br.B DIR *dirp;.PP.SM.B long.B telldir(dirp).br.B DIR *dirp;.PP.SM.B seekdir(dirp, loc).br.B DIR *dirp;.br.B long loc;.PP.SM.B rewinddir(dirp).br.B DIR *dirp;.PP.SM.B closedir(dirp).br.B DIR *dirp;.PP.SM.B cc ... -lndir.SH DESCRIPTIONThe purpose of this library is to simulatethe new flexible length directory names of 4.2bsd Unixon top of the old directory structure of 4.1bsd.It allows programs to be converted immediatelyto the new directory access interface,so that they need only be relinkedwhen 4.2bsd becomes available..PP.I opendiropens the directory named by.I filenameand associates a.I directory streamwith it..I opendirreturns a pointer to be used to identify the.I directory streamin subsequent operations.The pointer.SM.B NULLis returned if.I filenamecannot be accessed or is not a directory..PP.I readdirreturns a pointer to the next directory entry.It returns.B NULLupon reaching the end of the directory or detectingan invalid.I seekdiroperation..PP.I telldirreturns the current location associated with the named.I directory stream..PP.I seekdirsets the position of the next.I readdiroperation on the.I directory stream.The new position reverts to the one associated with the.I directory streamwhen the.I telldiroperation was performed.Values returned by.I telldirare good only for the lifetime of the DIR pointer from which they are derived.If the directory is closed and then reopened, the .I telldirvalue may be invalidateddue to undetected directory compaction.It is safe to use a previous.I telldirvalue immediately after a call to.I opendirand before any calls to.I readdir..PP.I rewinddirresets the position of the named.I directory streamto the beginning of the directory..PP.I closedircauses the named.I directory streamto be closed,and the structure associated with the DIR pointer to be freed..PPSee /usr/include/dir.h for a description of the fields available ina directory entry.The preferred way to search the current directory for entry "name" is:.br.sp len = strlen(name);.br dirp = opendir(".");.br for (dp = readdir(dirp); dp != NULL; dp = readdir(dir)).br if (dp->d_namlen == len && !strcmp(dp->d_name, name)) {.br closedir(dirp);.br return FOUND;.br }.br closedir(dirp);.br return NOT_FOUND;.SH LINKINGThis library is accessed by specifying "-lndir" as thelast argument to the compile line, e.g.:.br.sp cc -o prog prog.c -lndir.SH "SEE ALSO"/usr/include/dir.h,open(2),close(2),read(2),lseek(2).SH AUTHORKirk McKusick.Report problems to mckusick@berkeley or ucbvax!mckusick.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -