为了理解readdir函数,首先需要理解DIR结构,以下是DIR的结构:
<span style="font-family:KaiTi_GB2312;font-size:14px;"><strong>typdef struct __dirstream
{
int fd; /* File descriptor. */
__libc_lock_define (, lock) /* Mutex lock for this structure. */
size_t allocation; /* Space allocated for the block. */
size_t size; /* Total valid data in the block. */
size_t offset; /* Current offset into the block. */
off_t filepos; /* Position of next entry to read. */
/* Directory block. */
char data[0] __attribute__ ((aligned (__alignof__ (void*))));
}DIR;
</strong></span>
接下来简