Files
oldlinux-files/Minix/2.0.0/wwwman/man3/directory.3.html
2024-02-19 00:21:39 -05:00

126 lines
3.5 KiB
HTML

<HTML>
<HEAD>
<TITLE>directory(3)</TITLE>
</HEAD>
<BODY>
<H1>directory(3)</H1>
<HR>
<PRE>
</PRE>
<H2>NAME</H2><PRE>
directory, opendir, readdir, rewinddir, closedir, telldir, seekdir -
directory routines
</PRE>
<H2>SYNOPSIS</H2><PRE>
<STRONG>#include</STRONG> <STRONG>&lt;sys/types.h&gt;</STRONG>
<STRONG>#include</STRONG> <STRONG>&lt;dirent.h&gt;</STRONG>
<STRONG>DIR</STRONG> <STRONG>*opendir(const</STRONG> <STRONG>char</STRONG> <STRONG>*</STRONG><EM>dirname</EM><STRONG>)</STRONG>
<STRONG>struct</STRONG> <STRONG>dirent</STRONG> <STRONG>*readdir(DIR</STRONG> <STRONG>*</STRONG><EM>dirp</EM><STRONG>)</STRONG>
<STRONG>void</STRONG> <STRONG>rewinddir(DIR</STRONG> <STRONG>*</STRONG><EM>dirp</EM><STRONG>)</STRONG>
<STRONG>int</STRONG> <STRONG>closedir(DIR</STRONG> <STRONG>*</STRONG><EM>dirp</EM><STRONG>)</STRONG>
<STRONG>#define</STRONG> <STRONG>_MINIX</STRONG> <STRONG>1</STRONG>
<STRONG>#include</STRONG> <STRONG>&lt;sys/types.h&gt;</STRONG>
<STRONG>#include</STRONG> <STRONG>&lt;dirent.h&gt;</STRONG>
<STRONG>long</STRONG> <STRONG>telldir(DIR</STRONG> <STRONG>*</STRONG><EM>dirp</EM><STRONG>)</STRONG>
<STRONG>int</STRONG> <STRONG>seekdir(DIR</STRONG> <STRONG>*</STRONG><EM>dirp</EM><STRONG>,</STRONG> <STRONG>long</STRONG> <EM>pos</EM><STRONG>)</STRONG>
</PRE>
<H2>DESCRIPTION</H2><PRE>
These routines form a system independent interface to access directories.
<STRONG>Opendir()</STRONG> opens the directory <EM>dirname</EM> and returns a pointer to this open
directory stream.
<STRONG>Readdir()</STRONG> reads one entry from the directory as a pointer to a structure
containing the field <STRONG>d_name</STRONG>, a character array containing the null-
terminated name of the entry.
<STRONG>Rewinddir()</STRONG> allows the directory to be read again from the beginning.
<STRONG>Closedir()</STRONG> closes the directory and releases administrative data.
The Minix specific functions <STRONG>telldir()</STRONG> and <STRONG>seekdir()</STRONG> allow one to get the
current position in the directory file and to return there later.
<STRONG>Seekdir()</STRONG> may only be called with a position returned by <STRONG>telldir()</STRONG> or 0
(rewind). These functions should not be used in portable programs.
</PRE>
<H2>SEE ALSO</H2><PRE>
<STRONG><A HREF="../man5/dir.5.html">dir(5)</A></STRONG>.
</PRE>
<H2>DIAGNOSTICS</H2><PRE>
<STRONG>Opendir()</STRONG> returns a null pointer if <EM>dirname</EM> can't be opened, or if it
can't allocate enough memory for the <STRONG>DIR</STRONG> structure.
<STRONG>Readdir()</STRONG> returns null if there are no more directory entries or on
error.
<STRONG>Closedir()</STRONG> and <STRONG>seekdir()</STRONG> returns 0 on success, -1 on error.
<STRONG>Telldir()</STRONG> returns -1 on error.
All of them set <STRONG>errno</STRONG> appropriately. <STRONG>Readdir()</STRONG> will only set <STRONG>errno</STRONG> on
error, not on end-of-dir, so you should set <STRONG>errno</STRONG> to zero beforehand, and
check its value if <STRONG>readdir()</STRONG> returns null.
</PRE>
<H2>NOTES</H2><PRE>
The return value of <STRONG>readdir()</STRONG> needs to be copied before the next
operation on the same directory if it is to be saved.
</PRE>
<H2>AUTHOR</H2><PRE>
Kees J. Bot (kjb@cs.vu.nl)
</PRE>
</BODY>
</HTML>