摘要: 下面介绍关于文件和目录操作的函数1.文件类型stat(),fstat()和lstat()函数fstat功能和stat类似,只是不以文件的路径称作为标识,而是用文件描述符标识目标文件,获得该文件的有关信息。lstat形式和功能都与stat类似,但是当目标文件是符号链接文件时,lstat返回该符号连接的有关信息。格式:#inlcude <sys/stat.h>#include <unistd.h>int stat(const chat *name, struct stat *buf);int fstat(int filedes, struct stat *buf);int 阅读全文
posted @ 2011-05-01 10:44 涵曦 阅读(1729) 评论(2) 推荐(1) 编辑
摘要: 以下函数为不带缓存的I/O(unbuffered I/O)函数对于内核而言,所有打开的文件都由一个非负整数描述(称为文件描述符)。下面介绍下文件I/O函数:(1)open此函数为打开或创建一个文件。成功则返回文件描述符;失败则返回-1。格式:#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>int open(const char *name, int oflag[|optional parameter][,mode]);(2)creat此函数为创建一个新文件。成功则返回文件描述符;失败则 阅读全文
posted @ 2011-05-01 09:01 涵曦 阅读(911) 评论(0) 推荐(1) 编辑