241 lines
6.9 KiB
HTML
241 lines
6.9 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>QlgReaddir()--Read Directory Entry (using NLS-enabled path name)</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 -->
|
||
|
<!-- Created by Yvonne Griffin for V5R1-->
|
||
|
<!-- 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>QlgReaddir()--Read Directory Entry (using NLS-enabled path name)</h2>
|
||
|
|
||
|
<div class="box" style="width: 60%;">
|
||
|
<br>
|
||
|
Syntax<br>
|
||
|
|
||
|
|
||
|
<pre>
|
||
|
#include <sys/types.h>
|
||
|
#include <dirent.h>
|
||
|
|
||
|
struct dirent_lg *QlgReaddir(DIR <em>*dirp</em>);
|
||
|
</pre>
|
||
|
|
||
|
Service Program Name: QP0LLIB1<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Default Public Authority: *USE<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Threadsafe: No; see Usage Notes for <a href=
|
||
|
"readdir.htm">readdir()</a>.<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
</div>
|
||
|
|
||
|
<p>The <strong>QlgReaddir()</strong> function, like the <strong>
|
||
|
readdir()</strong> function, returns a pointer to a structure describing the
|
||
|
next directory entry in the directory stream associated with <em>dirp</em>. The
|
||
|
difference is that the <strong>QlgReaddir()</strong> function takes a pointer
|
||
|
to a <samp>dirent_lg</samp> structure, while <strong>readdir()</strong> takes a
|
||
|
pointer to a <samp>dirent</samp> structure.</p>
|
||
|
|
||
|
<p>Limited information on the <em>dirp</em> parameter is provided here. For
|
||
|
more information on the <em>dirp</em> parameter and for a discussion of
|
||
|
authorities required, return values, and related information, see <a href=
|
||
|
"readdir.htm">readdir()</a>--Read Directory Entry.</p>
|
||
|
|
||
|
<br>
|
||
|
<h3>Parameters</h3>
|
||
|
|
||
|
<dl>
|
||
|
<dt><strong><em>dirp</em></strong></dt>
|
||
|
|
||
|
<dd>(Input) A pointer to DIR that refers to the open directory stream to be
|
||
|
read. This pointer is returned by <strong>QlgOpendir()</strong>.
|
||
|
|
||
|
<p>A <samp>dirent_lg</samp> structure has the following contents:</p>
|
||
|
|
||
|
<table border>
|
||
|
<tr>
|
||
|
<td align="left" valign="top" width="20%">char</td>
|
||
|
<td align="left" valign="top" width="20%">d_reserved1[16]</td>
|
||
|
<td align="left" valign="top" width="60%">Reserved.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">unsigned int</td>
|
||
|
<td align="left" valign="top">d_fileno_gen_id</td>
|
||
|
<td align="left" valign="top">The generation ID associated with the file
|
||
|
ID.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">ino_t</td>
|
||
|
<td align="left" valign="top">d_fileno</td>
|
||
|
<td align="left" valign="top">The file ID of the file. This number uniquely
|
||
|
identifies the object within a file system.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">unsigned int</td>
|
||
|
<td align="left" valign="top">d_reclen</td>
|
||
|
<td align="left" valign="top">The length of the directory entry in bytes.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">int</td>
|
||
|
<td align="left" valign="top">d_reserved3</td>
|
||
|
<td align="left" valign="top">Reserved.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">char</td>
|
||
|
<td align="left" valign="top">d_reserved4[6]</td>
|
||
|
<td align="left" valign="top">Reserved.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">char</td>
|
||
|
<td align="left" valign="top">d_reserved5[2]</td>
|
||
|
<td align="left" valign="top">Reserved.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">Qlg_Path_Name_T</td>
|
||
|
<td align="left" valign="top">d_lg_name</td>
|
||
|
<td align="left" valign="top">A Qlg_Path_Name_T that gives the name of a file
|
||
|
in the directory. The path name is not null-terminated within the structure.
|
||
|
The structure also provides National Language Support information, which
|
||
|
includes ccsid, country_id, and language_id. This structure has a maximum
|
||
|
length of {_QP0L_DIR_NAME_LG} bytes. For more information on the
|
||
|
Qlg_Path_Name_T structure, see <a href="../apiref/pns.htm">Path name format</a>.</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</dd>
|
||
|
</dl>
|
||
|
|
||
|
<br>
|
||
|
<h3>Related Information</h3>
|
||
|
|
||
|
<ul>
|
||
|
<li><a href="readdir.htm">readdir()</a>--Read Directory Entry<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li><a href="opendiru.htm">QlgOpendir()</a>--Open Directory (using NLS-enabled
|
||
|
path name)<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li><a href="pathconfu.htm">QlgPathconf()</a>--Get Configurable Path Name
|
||
|
Variables (using NLS-enabled path name)</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 reads the contents of a root directory:</p>
|
||
|
|
||
|
<pre>
|
||
|
#include <sys/types.h>
|
||
|
#include <dirent.h>
|
||
|
#include <errno.h>
|
||
|
#include <stdio.h>
|
||
|
|
||
|
main() {
|
||
|
|
||
|
typedef struct my_dirent_lg
|
||
|
{
|
||
|
struct dirent_lg *entry;
|
||
|
char d_lg_name[1];
|
||
|
};
|
||
|
|
||
|
struct my_dirent_lg lg_struct;
|
||
|
struct dirent_lg *entry;
|
||
|
#define mypath "/"
|
||
|
const char US_const[3]= "US";
|
||
|
const char Language_const[4]="ENU";
|
||
|
typedef struct pnstruct
|
||
|
{
|
||
|
Qlg_Path_Name_T qlg_struct;
|
||
|
char pn[100]; /* This array size must be >= */
|
||
|
/* the length of the path name */
|
||
|
/* or this must be a pointer */
|
||
|
/* to the path name. */
|
||
|
};
|
||
|
|
||
|
struct pnstruct path;
|
||
|
DIR *dir;
|
||
|
|
||
|
/***************************************************************/
|
||
|
/* Initialize Qlg_Path_Name_T parameters */
|
||
|
/***************************************************************/
|
||
|
memset((void*)&path, 0x00, sizeof(struct pnstruct));
|
||
|
path.qlg_struct.CCSID = 37;
|
||
|
memcpy(path.qlg_struct.Country_ID,US_const,2);
|
||
|
memcpy(path.qlg_struct.Language_ID,Language_const,3);
|
||
|
path.qlg_struct.Path_Type = QLG_CHAR_SINGLE;
|
||
|
path.qlg_struct.Path_Length = sizeof(mypath)-1;
|
||
|
path.qlg_struct.Path_Name_Delimiter[0] = '/';
|
||
|
memcpy(path.pn,mypath,sizeof(mypath)-1);
|
||
|
|
||
|
if ((dir = QlgOpendir((Qlg_Path_Name_T *)&path)) == NULL)
|
||
|
perror("QlgOpendir() error");
|
||
|
else {
|
||
|
puts("contents of root:");
|
||
|
while ((entry = QlgReaddir(dir)) != NULL)
|
||
|
printf(" %s\n", entry->d_lg_name);
|
||
|
closedir(dir);
|
||
|
}
|
||
|
}
|
||
|
</pre>
|
||
|
|
||
|
<p><strong>Output:</strong></p>
|
||
|
|
||
|
<pre>
|
||
|
contents of root:
|
||
|
.
|
||
|
..
|
||
|
QSYS.LIB
|
||
|
QDLS
|
||
|
QOpenSys
|
||
|
QOPT
|
||
|
home
|
||
|
</pre>
|
||
|
|
||
|
<hr>
|
||
|
API introduced: V5R1
|
||
|
|
||
|
<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>
|
||
|
|