stat函数说明
来源:互联网 发布:通达信布林线boll源码 编辑:程序博客网 时间:2024/06/13 07:07
学习,stat,lstat,fstat
1 函数都是获取文件(普通文件,目录,管道,socket,字符,块()的属性。
函数原型
#include <sys/stat.h>
int stat(const char *restrict pathname, struct stat *restrict buf);
int stat(const char *restrict pathname, struct stat *restrict buf);
提供文件名字,获取文件对应属性。
int fstat(int filedes, struct stat *buf);
int fstat(int filedes, struct stat *buf);
通过文件描述符获取文件对应的属性。
int lstat(const char *restrict pathname, struct stat *restrict buf);
int lstat(const char *restrict pathname, struct stat *restrict buf);
连接文件描述命,获取文件属性。
2 文件对应的属性
struct stat {
mode_t st_mode; //文件对应的模式,文件,目录等
ino_t st_ino; //inode节点号
dev_t st_dev; //设备号码
dev_t st_rdev; //特殊设备号码
nlink_t st_nlink; //文件的连接数
uid_t st_uid; //文件所有者
gid_t st_gid; //文件所有者对应的组
off_t st_size; //普通文件,对应的文件字节数
time_t st_atime; //文件最后被访问的时间
time_t st_mtime; //文件内容最后被修改的时间
time_t st_ctime; //文件状态改变时间
blksize_t st_blksize; //文件内容对应的块大小
blkcnt_t st_blocks; //伟建内容对应的块数量
};
mode_t st_mode; //文件对应的模式,文件,目录等
ino_t st_ino; //inode节点号
dev_t st_dev; //设备号码
dev_t st_rdev; //特殊设备号码
nlink_t st_nlink; //文件的连接数
uid_t st_uid; //文件所有者
gid_t st_gid; //文件所有者对应的组
off_t st_size; //普通文件,对应的文件字节数
time_t st_atime; //文件最后被访问的时间
time_t st_mtime; //文件内容最后被修改的时间
time_t st_ctime; //文件状态改变时间
blksize_t st_blksize; //文件内容对应的块大小
blkcnt_t st_blocks; //伟建内容对应的块数量
};
可以通过上面提供的函数,返回一个结构体,保存着文件的信息
- stat函数说明
- stat函数说明转
- stat函数说明
- Linux函数stat说明
- stat,lstat,fstat 函数说明
- 关于linux 中stat函数的相关参数说明
- stat函数
- stat函数
- stat函数
- stat函数
- stat函数
- stat 函数
- stat函数
- stat函数
- stat函数
- stat函数
- stat函数
- stat函数
- 讨厌失败
- 写入出字符串到一个文件而不覆盖原文件的内容(追加)
- 50种方法巧妙优化你的SQL Server数据库
- 在vs2008下使用cygwin(1):前言
- “文件共享锁定数溢出” 原因及解决方法
- stat函数说明
- accept()函数说明
- 水晶报表打包
- JasperReport详细介绍(三)
- Flex 跨域访问解决方案
- javascript获取IE客户端IP及MAC的实现
- JasperReport报表设计总结(一)
- Linux 笔试题1(填空)
- delphi 动态数组和静态数组首地址的区别