fstat
相关函数: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
fstat的更多相关文章
- C语言:stat,fstat和lstat函数
这三个函数的功能是一致的,都用于获取文件相关信息,但应用于不同的文件对象.对于函数中给出pathname参数,stat函数返回与此命名文件有关的信息结构,fstat函数获取已在描述符fields上打开 ...
- 获取文件属性信息之stat、fstat和lstat
UNIX文件系统是目录和文件组成的一种层次结构.目录(directory)是一个包含许多目录项的文件,在逻辑上,可以认为每个目录项都包含一个文件名,同时还包含说明该文件属性的信息.文件属性是指文件类型 ...
- 文件和目录之stat、fstat和lstat函数
#include <sys/stat.h> int stat( const char *restrict pathname, struct stat *restrict buf ); in ...
- fstat - 读取文件相关信息
#fstat读取到的信息 ["dev"]=> int(16777220) ["ino"]=> int(66880002) ["mode&q ...
- fstat().stat()函数
int stat(const char *path, struct stat *buf); int fstat(int fd, struct stat *buf); 唯一不同是参数不同,其他一样. 文 ...
- stat(),lstat(),fstat() 获取文件/目录的相关信息
stat 的使用 Linux有个命令,ls -l,效果如下: 这个命令能显示文件的类型.操作权限.硬链接数量.属主.所属组.大小.修改时间.文件名.它是怎么获得这些信息的呢,请看下面的讲解. stat ...
- stat,fstat,lstat三者区别
fstat ,lstat,stat; 头文件:#include<sys/stat.h> #include<sys/types.h> #include<unistd.h&g ...
- fstat函数
一.函数原型 #include<sys/stat.h> #include<unistd.h> int fstat(int fildes,struct stat *buf); 返 ...
- fopen & fcolse & fseek & ftell & fstat 文件操作函数测试
1.文件大小查询file_size.c 方法一:fseek + ftell: 方法二:ftell #include <stdio.h> #include <fcntl.h> # ...
- 文件权限控制篇access alphasort chdir chmod chown chroot closedir fchdir fchmod fchown fstat ftruncate getcwd
access(判断是否具有存取文件的权限) 相关函数 stat,open,chmod,chown,setuid,setgid 表头文件 #include<unistd.h> 定义函数 in ...
随机推荐
- SharePoint 2013 附加内容数据库后出现404错误
本文讲述怎样解决SharePoint 2013 加内容数据库(Content DataBase)后出现404错误. 笔者依照http://technet.microsoft.com/en-us/lib ...
- jQuery中on()方法用法实例
这篇文章主要介绍了jQuery中on()方法用法,实例分析了on()方法的功能.定义及在匹配元素上绑定一个或者多个事件处理函数的使用技巧,需要的朋友可以参考下 本文实例讲述了jQuery中on()方法 ...
- UVA10954:Add All(优先队列)
题目:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=68990#problem/O 题目需求:在数组中拿出两个数相加,再把结果放回数组中再 ...
- HDU1520:Anniversary party(树形dp第一发)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1520 一个公司去参加宴会,要求去的人不能有直接领导关系,给出每一个人的欢乐值,和L K代表K是L的直接领导 ...
- django 使用form验证用户名和密码
form验证可以减少查询数据库,所以代码先预先验证,有问题可以返回给前端显示 1.在users文件夹下新建forms.py文件,用来验证用户名和密码是否为空,密码长度是否大于6 # -*- codin ...
- Python(进程线程)
一 理论基础: ''' 一 操作系统的作用: 1:隐藏丑陋复杂的硬件接口,提供良好的抽象接口 2:管理.调度进程,并且将多个进程对硬件的竞争变得有序 二 多道技术: 1.产生背景:针对单核,实现并发 ...
- 20. Valid Parentheses(括号匹配,用桟)
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the inpu ...
- Spring AOP (事务管理)
一.声明式事务管理的概括 声明式事务(declarative transaction management)是Spring提供的对程序事务管理的方式之一. Spring的声明式事务顾名思义就是采用声明 ...
- react-native 解决Could not find method android() for arguments问题
运行命令行:react-native run-android 报错 Error:(23, 0) Could not find method android() for arguments [****] ...
- LigerUI ligerComboBox 下拉框 表格 多选无效
$("#txt1").ligerComboBox({ width: 250, slide: false, selectBoxWidth: 500, selectBoxHeight: ...