<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[沧海一粟]]></title> 
<link>http://www.dzhope.com/index.php</link> 
<description><![CDATA[Web系统架构与服务器运维,php开发]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[沧海一粟]]></copyright>
<item>
<link>http://www.dzhope.com/post//</link>
<title><![CDATA[readdir读取目录]]></title> 
<author>jed &lt;jed521@163.com&gt;</author>
<category><![CDATA[代码编程]]></category>
<pubDate>Fri, 29 Sep 2006 09:11:42 +0000</pubDate> 
<guid>http://www.dzhope.com/post//</guid> 
<description>
<![CDATA[ 
	相关函数：open，opendir，closedir，rewinddir，seekdir，telldir，scandir<br/>表头文件：#include &nbsp;&lt;sys/types.h&gt;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #include &nbsp;&lt;dirent.h&gt;<br/>定义函数： struct &nbsp;dirent &nbsp;*readdir(DIR *dir)<br/>函数说明： readdir()返回参数dir目录流的下个目录进入点。结构dirent定义如下：<br/>struct &nbsp;dirent<br/>{<br/> &nbsp; &nbsp;ino_t &nbsp;d_ino;<br/> &nbsp; &nbsp;ff_t &nbsp; d_off;<br/> &nbsp; &nbsp;signed &nbsp;short int &nbsp;d_reclem;<br/> &nbsp; &nbsp;unsigned &nbsp;char &nbsp;d_type;<br/> &nbsp; &nbsp;char &nbsp; d_name[256];<br/>}<br/><br/>d_ino &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 此目录进入点的inode<br/>d_off &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 目录文件开头到此目录进入点的位移<br/>d_reclen &nbsp; &nbsp; &nbsp; _name的长度，不包含NULL字符<br/>d_type &nbsp; &nbsp; &nbsp; &nbsp; d_name所指的文件类型<br/>d_name &nbsp; &nbsp; &nbsp; &nbsp;文件名<br/><br/>返回值：成功则返回下个目录进入点。有错误发生或读取到目录文件尾则返回NULL<br/>附加说明： EBADF参数dir为无效的目录流<br/><br/>范例：<br/>/* 读取/etc/rc.d目录文件结构，然后显示该目录下的文件 */<br/><br/>#include &nbsp;&lt;sys/types.h&gt;<br/>#include &nbsp;&lt;dirent.h&gt;<br/>#include &nbsp;&lt;unistd.h&gt;<br/><br/>main()<br/>{<br/> &nbsp; &nbsp; DIR &nbsp;*dir;<br/> &nbsp; &nbsp; struct &nbsp;dirent &nbsp;*ptr;<br/> &nbsp; &nbsp; int &nbsp;i;<br/><br/> &nbsp; &nbsp; dir=opendir(&quot;/etc/rc.d&quot;);<br/> &nbsp; &nbsp; while((ptr=readdir(dir)) != NULL)<br/> &nbsp; &nbsp; {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf(&quot;d_name: %s&#92;n&quot;, ptr-&gt;d_name);<br/> &nbsp; &nbsp; }<br/> &nbsp; &nbsp; closedir(dir);<br/>}
]]>
</description>
</item><item>
<link>http://www.dzhope.com/post//#blogcomment</link>
<title><![CDATA[[评论] readdir读取目录]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.dzhope.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>