加入收藏 | 设为首页 | 会员中心 | 我要投稿 佛山站长网 (https://www.0757zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

linux系统编程之文件与I/O(三) 目录的操作

发布时间:2013-10-12 12:23:25 所属栏目:Linux 来源:站长网
导读:一、目录的访问 功能说明:打开一个目录 原型:DIR* opendir(char *pathname); 返回值: 打开成功,返回一个目录指针 打开失败,则返回NULL 功能说明:访问指定
一、目录的访问

功能说明:打开一个目录

原型:DIR*  opendir(char *pathname);

返回值:

打开成功,返回一个目录指针

打开失败,则返回NULL

功能说明:访问指定目录中下一个连接的细节

原型:struct  dirent*  readdir(DIR  *dirptr);

返回值:

返回一个指向dirent结构的指针,它包含指定目录中下一个连接的细节;

没有更多连接时,返回NULL

功能说明:关闭一个已经打开的目录

原型:int closedir (DIR  *dirptr);

返回值:调用成功返回0,失败返回-1

二、目录信息结构体

struct dirent
{
ino_t d_ino; /* inode number */
off_t d_off; /* offset to the next dirent */
unsigned short d_reclen; /* length of this record */
unsigned char d_type; /* type of file; not supported
by all file system types */
char d_name[256]; /* filename */
};

(编辑:佛山站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读