Files
oldlinux-files/Ref-docs/POSIX/susv3/basedefs/dirent.h.html
2024-02-19 00:21:47 -05:00

174 lines
6.3 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
<title>&lt;dirent.h&gt;</title>
</head>
<body bgcolor="white">
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
</script>
<basefont size="3"> <a name="&lt;dirent.h&gt;"></a> <a name="tag_13_08"></a><!-- &lt;dirent.h&gt; -->
<!--header start-->
<center><font size="2">The Open Group Base Specifications Issue 6<br>
IEEE Std 1003.1-2001<br>
Copyright &copy; 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
<!--header end-->
<hr size="2" noshade>
<h4><a name="tag_13_08_01"></a>NAME</h4>
<blockquote>dirent.h - format of directory entries</blockquote>
<h4><a name="tag_13_08_02"></a>SYNOPSIS</h4>
<blockquote class="synopsis">
<p><tt>#include &lt;dirent.h&gt;</tt></p>
</blockquote>
<h4><a name="tag_13_08_03"></a>DESCRIPTION</h4>
<blockquote>
<p>The internal format of directories is unspecified.</p>
<p>The <i>&lt;dirent.h&gt;</i> header shall define the following type:</p>
<dl compact>
<dt><b>DIR</b></dt>
<dd>A type representing a directory stream.</dd>
</dl>
<p>It shall also define the structure <b>dirent</b> which shall include the following members:</p>
<pre>
<tt><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">
ino_t d_ino </tt> File serial number. <tt>
<img src="../images/opt-end.gif" alt="[Option End]" border="0">
char d_name[] </tt> Name of entry. <tt>
</tt>
</pre>
<p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
The type <b>ino_t</b> shall be defined as described in <a href="sys/types.h.html"><i>&lt;sys/types.h&gt;</i></a> . <img src=
"../images/opt-end.gif" alt="[Option End]" border="0"></p>
<p>The character array <i>d_name</i> is of unspecified size, but the number of bytes preceding the terminating null byte shall not
exceed {NAME_MAX}.</p>
<p>The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.</p>
<pre>
<tt>int closedir(DIR *);
DIR *opendir(const char *);
struct dirent *readdir(DIR *);
<sup>[<a href="javascript:open_code('TSF')">TSF</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">
int readdir_r(DIR *restrict, struct dirent *restrict,
struct dirent **restrict);
<img src="../images/opt-end.gif" alt="[Option End]" border="0">
void rewinddir(DIR *);
<sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">
void seekdir(DIR *, long);
long telldir(DIR *);
<img src="../images/opt-end.gif" alt="[Option End]" border="0">
</tt>
</pre>
</blockquote>
<hr>
<div class="box"><em>The following sections are informative.</em></div>
<h4><a name="tag_13_08_04"></a>APPLICATION USAGE</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_13_08_05"></a>RATIONALE</h4>
<blockquote>
<p>Information similar to that in the <i>&lt;dirent.h&gt;</i> header is contained in a file <i>&lt;sys/dir.h&gt;</i> in 4.2 BSD and
4.3 BSD. The equivalent in these implementations of <b>struct dirent</b> from this volume of IEEE&nbsp;Std&nbsp;1003.1-2001 is
<b>struct direct</b>. The filename was changed because the name <i>&lt;sys/dir.h&gt;</i> was also used in earlier implementations
to refer to definitions related to the older access method; this produced name conflicts. The name of the structure was changed
because this volume of IEEE&nbsp;Std&nbsp;1003.1-2001 does not completely define what is in the structure, so it could be different
on some implementations from <b>struct direct</b>.</p>
<p>The name of an array of <b>char</b> of an unspecified size should not be used as an lvalue. Use of:</p>
<pre>
<tt>sizeof(d_name)
</tt>
</pre>
<p>is incorrect; use:</p>
<pre>
<tt>strlen(d_name)
</tt>
</pre>
<p>instead.</p>
<p>The array of <b>char</b> <i>d_name</i> is not a fixed size. Implementations may need to declare <b>struct dirent</b> with an
array size for <i>d_name</i> of 1, but the actual number of characters provided matches (or only slightly exceeds) the length of
the filename.</p>
</blockquote>
<h4><a name="tag_13_08_06"></a>FUTURE DIRECTIONS</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_13_08_07"></a>SEE ALSO</h4>
<blockquote>
<p><a href="sys/types.h.html"><i>&lt;sys/types.h&gt;</i></a> , the System Interfaces volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a
href="../functions/closedir.html"><i>closedir</i>()</a>, <a href="../functions/opendir.html"><i>opendir</i>()</a>, <a href=
"../functions/readdir.html"><i>readdir</i>()</a>, <a href="../functions/readdir_r.html"><i>readdir_r</i>()</a>, <a href=
"../functions/rewinddir.html"><i>rewinddir</i>()</a>, <a href="../functions/seekdir.html"><i>seekdir</i>()</a>, <a href=
"../functions/telldir.html"><i>telldir</i>()</a></p>
</blockquote>
<h4><a name="tag_13_08_08"></a>CHANGE HISTORY</h4>
<blockquote>
<p>First released in Issue 2.</p>
</blockquote>
<h4><a name="tag_13_08_09"></a>Issue 5</h4>
<blockquote>
<p>The DESCRIPTION is updated for alignment with the POSIX Threads Extension.</p>
</blockquote>
<h4><a name="tag_13_08_10"></a>Issue 6</h4>
<blockquote>
<p>The Open Group Corrigendum U026/7 is applied, correcting the prototype for <a href=
"../functions/readdir_r.html"><i>readdir_r</i>()</a>.</p>
<p>The <b>restrict</b> keyword is added to the prototype for <a href="../functions/readdir_r.html"><i>readdir_r</i>()</a>.</p>
</blockquote>
<div class="box"><em>End of informative text.</em></div>
<hr>
<hr size="2" noshade>
<center><font size="2"><!--footer start-->
UNIX &reg; is a registered Trademark of The Open Group.<br>
POSIX &reg; is a registered Trademark of The IEEE.<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>
<!--footer end-->
<hr size="2" noshade>
</body>
</html>