本文转载自:https://www.ccoder.cn/article/84
函数原型 #include <sys/stat.h> int stat(const char *restrict pathname, struct stat *restrict buf); 提供文件名字,获取文件对应属性。 int fstat(int filedes, struct stat *buf); 通过文件描述符获取文件对应的属性。 int lstat(const char *restrict pathname, struct stat *restrict buf); 类似于stat.但是当命名的文件是一个符号链接时,lstat返回该符号链接的有关信息,而不是由该符号链接引用文件 函数说明: 通过文件名filename获取文件信息,并保存在buf所指的结构体stat中返回值: 执行成功则返回0,失败返回-1,错误代码存于errno 第二个参数是个指针,它指向一个我们应提供的结构。这些函数填写由buf指向的结构。 该结构的实际定义可能所实施而有所不同,但其基本形式是: 函数原型