Project

General

Profile

Reqeditor-getting-started » closedir.html

Илья Рудаков, 01/14/2010 02:54 PM

 
<html><head><meta content="HTML Tidy, see www.w3.org" name="generator"></meta><meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"></meta><link rel="stylesheet" type="text/css" href="style.css"></link><title>closedir</title></head><body bgcolor="white"><script src="../jscript/codes.js" language="JavaScript" type="text/javascript"> </script><script src="../../reqtools.js" language="javascript"> </script><basefont size="3"></basefont><a name="closedir"></a><a name="tag_03_81"></a><center><font size="2">The Open Group Base Specifications Issue 6<br></br> IEEE Std 1003.1, 2004 Edition<br></br> Copyright &amp;copy; 2001-2004 The IEEE and The Open Group, All Rights reserved.</font></center><hr noshade="noshade" size="2"></hr><h4><a name="tag_03_81_01"></a>NAME</h4><blockquote>closedir - close a directory stream</blockquote><h4><a name="tag_03_81_02"></a>SYNOPSIS</h4><blockquote class="synopsis"> <p><code><tt>#include &lt;<a href="../basedefs/dirent.h.html">dirent.h</a>&gt;<br></br> <br></br> int closedir(DIR *</tt><i>dirp</i><tt>);<br></br> </tt></code></p> </blockquote><h4><a name="tag_03_81_03"></a>DESCRIPTION</h4><blockquote> <p id="closedir.03"><span id="closedir.01" class="req"><span class="reqstart" id="5a786953-6e3f-45ea-9bf8-10a9e9f14a9f" style="background-color:#FF9900">[</span><a name="req5a786953-6e3f-45ea-9bf8-10a9e9f14a9f"></a><span class="reqelem" id="closedir.01" attrs="{}"></span>The <i>closedir</i>() function shall close the directory stream referred to by the argument <i>dirp</i>. Upon return, the value
of <i>dirp</i> may no longer point to an accessible object of the type <b>DIR</b>.<span class="reqend" id="5a786953-6e3f-45ea-9bf8-10a9e9f14a9f" style="background-color:#FF9900">]</span></span> <span id="closedir.03" class="req"><span class="reqstart" id="1c54aa48-29bd-4e0a-adaf-6a433512b451" style="background-color:#FF9900">[</span><a name="req1c54aa48-29bd-4e0a-adaf-6a433512b451"></a><span class="reqelem" id="closedir.03" attrs="{}"></span>If a file descriptor is used to implement type <b>DIR</b>, that file descriptor shall be closed.<span class="reqend" id="1c54aa48-29bd-4e0a-adaf-6a433512b451" style="background-color:#FF9900">]</span></span></p> </blockquote><h4><a name="tag_03_81_04"></a>RETURN VALUE</h4><blockquote> <p><span id="closedir.04" class="req"><span class="reqstart" id="8148b4fd-3cdc-4a75-9006-79b191c6e35b" style="background-color:#FF9900">[</span><a name="req8148b4fd-3cdc-4a75-9006-79b191c6e35b"></a><span class="reqelem" id="closedir.04" attrs="{}"></span>Upon successful completion, <i>closedir</i>() shall return 0;<span class="reqend" id="8148b4fd-3cdc-4a75-9006-79b191c6e35b" style="background-color:#FF9900">]</span></span> <span id="closedir.05" class="req"><span class="reqstart" id="cb5f7cd6-05df-41f5-9ada-cad467d2eb4d" style="background-color:#FF9900">[</span><a name="reqcb5f7cd6-05df-41f5-9ada-cad467d2eb4d"></a><span class="reqelem" id="closedir.05" attrs="{}"></span>otherwise, -1 shall be returned and <i>errno</i> set to indicate
the error.<span class="reqend" id="cb5f7cd6-05df-41f5-9ada-cad467d2eb4d" style="background-color:#FF9900">]</span></span></p> </blockquote><h4><a name="tag_03_81_05"></a>ERRORS</h4><blockquote> <p id="closedir.90" title="MAY:POSIX_CLOSEDIR" class="req"><span class="reqstart" id="956b7999-af1e-4828-a1d3-fdfe1dcec64b" style="background-color:#FF9900">[</span><a name="req956b7999-af1e-4828-a1d3-fdfe1dcec64b"></a><span class="reqelem" id="closedir.90" attrs="{}"></span>The <i>closedir</i>() function may fail if:<span class="reqend" id="956b7999-af1e-4828-a1d3-fdfe1dcec64b" style="background-color:#FF9900">]</span></p> <dl compact="compact"> <span id="closedir.90.01" class="req"><span class="reqstart" id="291606d5-d76a-4779-8f59-d3b975404b99" style="background-color:#FF9900">[</span><a name="req291606d5-d76a-4779-8f59-d3b975404b99"></a><span class="reqelem" id="closedir.90.01" attrs="{}"></span> <dt>[EBADF]</dt> <dd>The <i>dirp</i> argument does not refer to an open directory stream.</dd> <span class="reqend" id="291606d5-d76a-4779-8f59-d3b975404b99" style="background-color:#FF9900">]</span></span><br></br><span id="closedir.90.02" class="req"><span class="reqstart" id="43e045ae-b400-4745-b57f-2543c8bb956f" style="background-color:#FF9900">[</span><a name="req43e045ae-b400-4745-b57f-2543c8bb956f"></a><span class="reqelem" id="closedir.90.02" attrs="{}"></span> <dt>[EINTR]</dt> <dd>The <i>closedir</i>() function was interrupted by a signal.</dd> <span class="reqend" id="43e045ae-b400-4745-b57f-2543c8bb956f" style="background-color:#FF9900">]</span></span> </dl> </blockquote><hr></hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_81_06"></a>EXAMPLES</h4><blockquote> <h5><a name="tag_03_81_06_01"></a>Closing a Directory Stream</h5> <p>The following program fragment demonstrates how the <i>closedir</i>() function is used.</p> <pre> <tt>...
DIR *dir;
struct dirent *dp;
...
if ((dir = opendir (".")) == NULL) {
...
} <br></br> while ((dp = readdir (dir)) != NULL) {
...
} <br></br> closedir(dir);
... </tt> </pre> </blockquote><h4><a name="tag_03_81_07"></a>APPLICATION USAGE</h4><blockquote> <p>None.</p> </blockquote><h4><a name="tag_03_81_08"></a>RATIONALE</h4><blockquote> <p>None.</p> </blockquote><h4><a name="tag_03_81_09"></a>FUTURE DIRECTIONS</h4><blockquote> <p>None.</p> </blockquote><h4><a name="tag_03_81_10"></a>SEE ALSO</h4><blockquote> <p><a href="opendir.html"><i>opendir</i>()</a>, the Base Definitions volume of IEEE&amp;nbsp;Std&amp;nbsp;1003.1-2001, <a href="../basedefs/dirent.h.html"><i>&lt;dirent.h&gt;</i></a></p> </blockquote><h4><a name="tag_03_81_11"></a>CHANGE HISTORY</h4><blockquote> <p>First released in Issue 2.</p> </blockquote><h4><a name="tag_03_81_12"></a>Issue 6</h4><blockquote> <p>In the SYNOPSIS, the optional include of the <a href="../basedefs/sys/types.h.html"><i>&lt;sys/types.h&gt;</i></a> header is
removed.</p> <p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p> <ul> <li> <p>The requirement to include <a href="../basedefs/sys/types.h.html"><i>&lt;sys/types.h&gt;</i></a> has been removed. Although <a href="../basedefs/sys/types.h.html"><i>&lt;sys/types.h&gt;</i></a> was required for conforming implementations of previous POSIX
specifications, it was not required for UNIX applications.</p> </li> <li> <p>The [EINTR] error condition is added as an optional error condition.</p> </li> </ul> </blockquote><div class="box"><em>End of informative text.</em></div><hr noshade="noshade" size="2"></hr><center><font size="2"> UNIX &amp;reg; is a registered Trademark of The Open Group.<br></br> POSIX &amp;reg; is a registered Trademark of The IEEE.<br></br> [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a> ]</font></center><hr noshade="noshade" size="2"></hr></body></html>
(27-27/29)