相关函数: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的更多相关文章

  1. C语言:stat,fstat和lstat函数

    这三个函数的功能是一致的,都用于获取文件相关信息,但应用于不同的文件对象.对于函数中给出pathname参数,stat函数返回与此命名文件有关的信息结构,fstat函数获取已在描述符fields上打开 ...

  2. 获取文件属性信息之stat、fstat和lstat

    UNIX文件系统是目录和文件组成的一种层次结构.目录(directory)是一个包含许多目录项的文件,在逻辑上,可以认为每个目录项都包含一个文件名,同时还包含说明该文件属性的信息.文件属性是指文件类型 ...

  3. 文件和目录之stat、fstat和lstat函数

    #include <sys/stat.h> int stat( const char *restrict pathname, struct stat *restrict buf ); in ...

  4. fstat - 读取文件相关信息

    #fstat读取到的信息 ["dev"]=> int(16777220) ["ino"]=> int(66880002) ["mode&q ...

  5. fstat().stat()函数

    int stat(const char *path, struct stat *buf); int fstat(int fd, struct stat *buf); 唯一不同是参数不同,其他一样. 文 ...

  6. stat(),lstat(),fstat() 获取文件/目录的相关信息

    stat 的使用 Linux有个命令,ls -l,效果如下: 这个命令能显示文件的类型.操作权限.硬链接数量.属主.所属组.大小.修改时间.文件名.它是怎么获得这些信息的呢,请看下面的讲解. stat ...

  7. stat,fstat,lstat三者区别

    fstat ,lstat,stat; 头文件:#include<sys/stat.h> #include<sys/types.h> #include<unistd.h&g ...

  8. fstat函数

    一.函数原型 #include<sys/stat.h> #include<unistd.h> int fstat(int fildes,struct stat *buf); 返 ...

  9. fopen & fcolse & fseek & ftell & fstat 文件操作函数测试

    1.文件大小查询file_size.c 方法一:fseek + ftell: 方法二:ftell #include <stdio.h> #include <fcntl.h> # ...

  10. 文件权限控制篇access alphasort chdir chmod chown chroot closedir fchdir fchmod fchown fstat ftruncate getcwd

    access(判断是否具有存取文件的权限) 相关函数 stat,open,chmod,chown,setuid,setgid 表头文件 #include<unistd.h> 定义函数 in ...

随机推荐

  1. Installshield 宏定义控制版本

    定义宏 在Build =>Setting => 以空格为准定义宏 使用宏 在方法里 #if 宏名称 代码 #else 代码 #endif

  2. 最简单的win7、win8免费升级正版win10图文教程

    https://www.microsoft.com/zh-cn/software-download/windows10 http://jingyan.baidu.com/article/19192ad ...

  3. 『HTML5挑战经典』是英雄就下100层-开源讲座(一)从天而降的英雄

    是英雄就下100层是一款经典的手机小游戏,以前是在诺基亚手机上十分有名.今天我们就用HTML5和lufylegend一步步地实现它. 一,准备工作 首先,你需要下载lufylegend,下载地址如下: ...

  4. MySQL整理(一)

    一.数据管理发展阶段 人工管理阶段→文件系统阶段→数据库系统阶段    二.数据库管理系统提供的功能   (1)数据定义语言DDL:提供数据定义语言定义数据库及各种对象,定义数据的完整性约束和保密限制 ...

  5. jsonp解决跨域问题

    日常开发网页中,时常遇到跨域问题,通常解决办法:后端提供的接口支持jsonp格式,前端采用dataType:jsonp. 一:Jquery封装的AJAX,dataType:jsonp格式的方法: $. ...

  6. Oracle trigger 触发器

    触发器使用教程和命名规范 目  录触发器使用教程和命名规范 11,触发器简介 12,触发器示例 23,触发器语法和功能 34,例一:行级触发器之一 45,例二:行级触发器之二 46,例三:INSTEA ...

  7. 如何检测浏览器是否安装了Adblock,uBlock Origin,Adguard,uBlock等广告屏蔽插件

    由于我们网站上的广告经常被一些广告插件给屏蔽掉,上级给我下达了一个检测浏览器是否安装了屏蔽广告的插件的任务. 经过研究,借鉴,参考,整合了如下三种解决方案.   方案一: 利用广告插件通过对含有goo ...

  8. Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) D - Dynamic Problem Scoring

    地址:http://codeforces.com/contest/807/problem/D 题目: D. Dynamic Problem Scoring time limit per test 2 ...

  9. Winter-2-STL-G Team Queue 解题报告及测试数据

    Time Limit:3000MS     Memory Limit:0KB Description Queues and Priority Queues are data structures wh ...

  10. Salesforce中通过SOAP API和Metadata API开发java的web server服务

    1.下载Salesforce平台中WSDL文件 在Salesforce中创建了自己需要用到的对象后,我们想要在别的应用中读写纪录到对象中,首先需要的是自己Salesforce平台的权限通过.登陆自己的 ...