目录操作符部分函数接口

函数接口

打开目录opendir

        #include <sys/types.h>

        #include <dirent.h>

        DIR *opendir(constchar*name);

                功能:打开目录

                参数:

                        name:目录路径

                返回值:

                        成功:目录流指针

                        失败:-1

关闭目录closedir

        #include <sys/types.h>

        #include <dirent.h>

        int closedir(DIR *dirp);

                功能:关闭目录

                参数:

                        dirp:目录流指针

                返回值:

                        成功0

                        失败-1

readdir读取目录内容

        #include <dirent.h>

        struct dirent * readdir (DIR *dirp);

                功能:读取目录中的内容

                参数:

                        dirp:目录流指针

                返回值:

                        成功:返回结构体指针

                        读到结尾:NULL

                        失败:NULL

struct dirent {

        ino_t d_ino; /* Inode number */         //文件inode号

        off_t d_off; /* Not an offset; see below */

        unsigned short d_reclen; /* Length of this record */

        unsigned char d_type; /* Type of file; not supported

        by all filesystem types */         //文件类型

        char d_name[256]; /* Null-terminated filename */        //文件名

};

修改路径chdir()

        #include <unistd.h>

        int chdir (const char*path);

                功能:改变当前所处的路径

                参数

                        path:文件路径

                返回值

                        成功:0

                        失败:-1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值