209 lines
5.3 KiB
HTML
209 lines
5.3 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
|
|
<title>rewinddir()--Reset Directory Stream to Beginning</title>
|
|
<!-- Begin Header Records ========================================== -->
|
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
|
<!-- US Government Users Restricted Rights -->
|
|
<!-- Use, duplication or disclosure restricted by -->
|
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
|
<!-- file cleaned -->
|
|
<!-- Unix2 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
|
|
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
|
|
<!-- Change History: -->
|
|
<!-- 011022 JTROUS Changes from API Review 1, V5R2 -->
|
|
<!-- This file has undergone html cleanup June 2002 by JET -->
|
|
<!--End Header Records -->
|
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
|
</head>
|
|
<body>
|
|
<a name="Top_Of_Page"></a>
|
|
<!-- Java sync-link -->
|
|
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript">
|
|
</script>
|
|
|
|
<h2>rewinddir()--Reset Directory Stream to Beginning</h2>
|
|
|
|
<div class="box" style="width: 60%;">
|
|
<br>
|
|
Syntax<br>
|
|
|
|
|
|
<pre>
|
|
#include <sys/types.h>
|
|
#include <dirent.h>
|
|
|
|
void rewinddir(DIR <em>*dirp</em>);
|
|
</pre>
|
|
|
|
Service Program Name: QP0LLIB1<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Default Public Authority: *USE<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Threadsafe: Yes<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
</div>
|
|
|
|
<p>The <strong>rewinddir()</strong> function "rewinds" the position of an open
|
|
directory stream to the beginning. <em>dirp</em> points to a <samp>DIR</samp>
|
|
associated with an open directory stream.</p>
|
|
|
|
<p>The next call to <strong>readdir()</strong> reads the first entry in the
|
|
directory. If the contents of the directory have changed since the directory
|
|
was opened and <strong>rewinddir()</strong> is called, subsequent calls to
|
|
<strong>readdir()</strong> read the changed contents.</p>
|
|
|
|
<br>
|
|
<h3>Parameters</h3>
|
|
|
|
<dl>
|
|
<dt><strong><em>dirp</em></strong></dt>
|
|
|
|
<dd>(Input) A pointer to a <samp>DIR</samp> that refers to the open directory
|
|
stream to be rewound. This pointer is returned by the <samp>opendir()</samp>
|
|
function.</dd>
|
|
</dl>
|
|
|
|
<br>
|
|
<h3>Authorities</h3>
|
|
|
|
<p>No authorization is required. Authorization is verified during <strong>
|
|
opendir()</strong>.</p>
|
|
|
|
<br>
|
|
<h3>Return Value</h3>
|
|
|
|
<p>None.</p>
|
|
|
|
<br>
|
|
<h3>Error Conditions</h3>
|
|
|
|
<p>None.</p>
|
|
|
|
<br>
|
|
<h3>Error Messages</h3>
|
|
|
|
<p>The following messages may be sent from this function:</p>
|
|
|
|
<table width="100%" cellpadding="5">
|
|
<tr>
|
|
<th align="left" valign="top">Message ID</th>
|
|
<th align="left" valign="top">Error Message Text</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td width="15%" valign="top">CPE3418 E</td>
|
|
<td width="85%" valign="top">Possible APAR condition or hardware failure.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top">CPF1F05 E</td>
|
|
<td valign="top">Directory handle not valid.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top">CPF3CF2 E</td>
|
|
<td valign="top">Error(s) occurred during running of &1 API.</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<br>
|
|
<br>
|
|
<h3><a name="USAGE_NOTES">Usage Notes</a></h3>
|
|
|
|
<ol type="1">
|
|
<li>If the <em>dirp</em> argument passed to <strong>rewinddir()</strong> does
|
|
not refer to an open directory, unexpected results could occur.<br>
|
|
</li>
|
|
|
|
<li>Files that are added to the directory after <strong>opendir()</strong> or
|
|
<strong>rewinddir()</strong> may not be returned on calls to <strong>
|
|
readdir()</strong>.</li>
|
|
</ol>
|
|
|
|
<br>
|
|
<h3>Related Information</h3>
|
|
|
|
<ul>
|
|
<li>The <<strong>sys/types.h</strong>> file (see <a href="unix13.htm">
|
|
Header Files for UNIX-Type Functions</a>)<br>
|
|
</li>
|
|
|
|
<li>The <<strong>dirent.h</strong>> file (see <a href="unix13.htm">Header
|
|
Files for UNIX-Type Functions</a>)<br>
|
|
</li>
|
|
|
|
<li><a href="opendir.htm">opendir()</a>--Open Directory<br>
|
|
</li>
|
|
|
|
<li><a href="readdir.htm">readdir()</a>--Read Directory Entry<br>
|
|
</li>
|
|
|
|
<li><a href="closedir.htm">closedir()</a>--Close Directory</li>
|
|
</ul>
|
|
|
|
<br>
|
|
<h3>Example</h3>
|
|
|
|
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
|
|
for information pertaining to code examples.</p>
|
|
|
|
<p>The following example produces the contents of a directory by opening it,
|
|
rewinding it, and closing it:</p>
|
|
|
|
<pre>
|
|
#include <sys/types.h>
|
|
#include <dirent.h>
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
|
|
main() {
|
|
DIR *dir;
|
|
struct dirent *entry;
|
|
|
|
if ((dir = opendir("/")) == NULL)
|
|
perror("opendir() error");
|
|
else {
|
|
puts("contents of root:");
|
|
while ((entry = readdir(dir)) != NULL)
|
|
printf("%s ", entry->d_name);
|
|
rewinddir(dir);
|
|
puts("");
|
|
while ((entry = readdir(dir)) != NULL)
|
|
printf("%s ", entry->d_name);
|
|
closedir(dir);
|
|
puts("");
|
|
}
|
|
}
|
|
</pre>
|
|
|
|
<p><strong>Output:</strong></p>
|
|
|
|
<pre>
|
|
contents of root:
|
|
. .. QSYS.LIB QDLS QOpenSys QOPT home
|
|
. .. QSYS.LIB QDLS QOpenSys QOPT home newdir
|
|
</pre>
|
|
|
|
<br>
|
|
<hr>
|
|
API introduced: V3R1
|
|
|
|
<hr>
|
|
<center>
|
|
<table cellpadding="2" cellspacing="2">
|
|
<tr align="center">
|
|
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
|
|
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a></td>
|
|
</tr>
|
|
</table>
|
|
</center>
|
|
</body>
|
|
</html>
|
|
|