#include <dirent.h>
文件夹操作函数。GCC,非ANSI C。
作用不作为C标准的部分,而是被认为“冒充标准”并且可靠地是便携式的在平台之间。
含有以下类型和函数
DIR *dir; //DIR表示目录类型
/* struct dirent 结构体包含:
* ino_t d_ino file serial number
) char d_name[] name of entry
*/
struct dirent *stDir;
int closedir(DIR *);
DIR *opendir(const char *);
struct dirent *readdir(DIR *);
int readdir_r(DIR *, struct dirent *, struct dirent **);
void rewinddir(DIR *);
void seekdir(DIR *, long int);
long int telldir(DIR *);
详见:http://pubs.opengroup.org/onlinepubs/007908799/xsh/dirent.h.html
-----------------------------------------------------------------------------------------------------
NAME dirent.h - format of directory entries SYNOPSIS
#include <dirent.h>
DESCRIPTION The internal format of directories is unspecified.
The <dirent.h> header defines the following data type through typedef:
DIR A type representing a directory stream.It also defines the structure dirent which includes the following members:
ino_t d_ino file serial number
char d_name[] name of entry
The type ino_t is defined as described in <sys/types.h>.
The character array d_name is of unspecified size, but the number of bytes preceding the terminating null byte will not exceed {NAME_MAX}.
The following are declared as functions and may also be defined as macros. Function prototypes must be provided for use with an ISO C compiler.
int closedir(DIR *);
DIR * opendir(const char *);
struct dirent * readdir(DIR *);
int readdir_r(DIR *, struct dirent *, struct dirent **);
void rewinddir(DIR *);
void seekdir(DIR *, long int);
long int telldir(DIR *);
转自:http://hi.baidu.com/w_dalu/blog/item/853ed146cb5c821b6a63e528.html
本文详细解析了 dirent.h 头文件中提供的用于文件夹操作的函数,包括 DIR 类型、dirent 结构体以及相关函数如 closedir、opendir、readdir 等的使用方法。

2万+

被折叠的 条评论
为什么被折叠?



