fstat
2024-08-28 17:35:12
相关函数:stat, lstat, chmod, chown, readlink, utime
头文件:#include <sys/stat.h> #include <unistd.h>
定义函数:int fstat(int fildes, struct stat *buf);
函数说明:fstat()用来将参数fildes 所指的文件状态, 复制到参数buf 所指的结构中(struct stat). Fstat()与stat()作用完全相同, 不同处在于传入的参数为已打开的文件描述词. 详细内容请参考stat().
返回值:执行成功则返回0, 失败返回-1, 错误代码存于errno.
范例
#include <sys/stat.h>
#include <unistd.h>
#include <fcntk.h>
main()
{
struct stat buf;
int fd;
fd = open("/etc/passwd", O_RDONLY);
fstat(fd, &buf);
printf("/etc/passwd file size +%d\n ", buf.st_size);
}
执行:
/etc/passwd file size = 705
最新文章
- 初学者--bootstrap(六)组件中的下拉菜单----在路上(10)
- Sprint(第十一天11.24)
- SQLServer存储过程和触发器学习记录及简单例子
- IE下默认TD colspan rowspan值为1
- 详细安装ss的过程(vultr)
- Bootstrap 图标菜单按钮组件
- 超强vim配置
- ie7下 滚动条内容不动问题
- LeetCode Contains Duplicate (判断重复元素)
- codeforces 336C Vasily the Bear and Sequence(贪心)
- CSS中的特殊性、继承、层叠
- C语言,realloc
- Hadoop入门进阶步步高(五)-搭建Hadoop集群
- spring学习总结一----控制反转与依赖注入
- 用户登录(Material Design + Data-Binding + MVP架构模式)实现
- 外部地址访问xampp
- Ffmpeg简介
- ThreadLocal(线程绑定)
- JavaScript之DOM对象获取(1)
- Scala - 快速学习07 - 模式匹配