#include <sys/stat.h>
 
int fstat(int fildes, struct stat *buf);
获取文件信息 
int lstat(const char* restrictpath, struct stat *restrictbuf);
获取文件信息 
int stat(const char* restrictpath, struct stat *restrictbuf);
获取文件信息 
   

​
   
   
   
int fstat(int fildes, struct stat *buf) //用于已经open的文件

/* 二者可用于还未打开的文件,其中,如果是软连接文件, lstat描述的是链接本身,stat则是描述链接所指向的文件 */
int lstat(const char *restrictpath, struct stat *restrictbuf);
int stat(const char *restrictpath, struct stat *restrictbuf);
struct stat *buf  //这是stat.h中的一个结构体,用于记录文件信息

   struct stat{                /* when _DARWIN_FEATURE_64_BIT_INODE is defined */
dev_t st_dev; /* ID of device containing file 文件保存的设备*/
mode_t st_mode; /* Mode of file (see below) 文件权限与文件类型信息*/
nlink_t st_nlink; /* Number of hard links 该文件上硬链接的数量*/
ino_t st_ino; /* File serial number 该文件的inode */
uid_t st_uid; /* User ID of the file 该文件的用户id*/
gid_t st_gid; /* Group ID of the file 该文件的组id*/
dev_t st_rdev; /* Device ID */
struct timespecst_atimespec; /* time of last access 上次被访问的时间戳*/
struct timespecst_mtimespec; /* time of last data modification 上次被修改的时间戳*/
struct timespecst_ctimespec; /* time of last status change */
struct timespecst_birthtimespec; /* time of file creation(birth) */
off_t st_size; /* file size, in bytes */
blkcnt_t st_blocks; /* blocks allocated for file */
blksize_t st_blksize; /* optimal blocksize for I/O */
uint32_t st_flags; /* user defined flags for file */
uint32_t st_gen; /* file generation number */
int32_t st_lspare; /* RESERVED: DO NOT USE! */
int64_t st_qspare[]; /* RESERVED: DO NOT USE! */
};

linux文件操作篇 (三) 文件状态和操作属性的更多相关文章

  1. Util应用程序框架公共操作类(三):数据类型转换公共操作类(扩展篇)

    上一篇以TDD方式介绍了数据类型转换公共操作类的开发,并提供了单元测试和实现代码,本文将演示通过扩展方法来增强公共操作类,以便调用时更加简化. 下面以字符串转换为List<Guid>为例进 ...

  2. python学习笔记三 文件操作(基础篇)

    文件操作 打开文件 open(name[,mode[,buffering]])   open函数使用一个文件名作为强制参数,然后返回一个文件对象.[python 3.5 把file()删除掉]   w ...

  3. Python【第三篇】文件操作、字符编码

    一.文件操作 文件操作分为三个步骤:文件打开.操作文件.关闭文件,但是,我们可以用with来管理文件操作,这样就不需要手动来关闭文件. 实现原理: import contextlib @context ...

  4. Python之路【第三篇】:文件操作

    一.文件操作步骤 打开文件,得到文件句柄并赋值给一个变量 通过句柄对文件进行操作 关闭文件 歌名:<大火> 演唱:李佳薇 作词:姚若龙 作曲:马奕强 歌词: 有座巨大的停了的时钟 倾倒在赶 ...

  5. linux文件IO操作篇 (二) 缓冲文件

    2. 缓冲文件操作 //规模较大 实时性低的文件 //当数据长度快要超过缓冲区的范围时,或者时间周期达到时,数据才被送往指定位置 //需要使用FILE * 作为文件标识符 //stdin 标准输入 / ...

  6. linux文件IO操作篇 (一) 非缓冲文件

    文件IO操作分为 2 种 非缓冲文件IO 和 缓冲文件IO 它们的接口区别是 非缓冲 open() close() read() write() 缓冲 fopen() fclose() fread() ...

  7. linux文件操作篇 (四) 目录操作

    #include <sys/stat.h>#include <unistd.h>#include <dirent.h> //创建文件夹 路径 掩码 int mkdi ...

  8. linux文件操作篇 (二) 打开和关闭文件

    2.1 打开文件和关闭文件 #include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>  头文件 i ...

  9. Linux(三) - 文件操作相关命令

    Ctl-A 光标移动到行首 Ctl-C 终止命令 Ctl-D 注销登录 Ctl-E 光标移动到行尾 Ctl-U 删除光标到行首的所有字符,在某些设置下,删除全行 Ctl-W 删除当前光标到前边的最近一 ...

随机推荐

  1. check_mk通用应用检测插件

    客户端mk_tvmapp import json filename = '/tmp/tvmapp.json' print '<<<tvmapp>>>' for a ...

  2. AOP的实现

    AOP基于xml配置方式实现 Spring基于xml开发AOP 定义目标类(接口及实现类) /** * 目标类 */ public interface UserService { //业务方法 pub ...

  3. java实现多文件上传01

    1.html代码 <html> <head> <link rel="stylesheet" type="text/css" hre ...

  4. 团队合作之Scrum

    CCSU小助手 一:开发团队简介 队名:瓜队 组员:钟文兴.周畅.吉刘磊.唐仲勋 宣言:We are a team at any time! 团队项目描述: 内容:“生活在长大”: 目标:为了方便对学 ...

  5. springIOC的那些事

       springIOC动态代理的那些事儿 1.发现问题 今天在使用spring的IOC容器时发现了这样的一个问题: 首先有一个接口定义如下: public interface BookShopSer ...

  6. ABAP宏的调试

    我们都知道高级语言宏一般是无法调试的.但是ABAP的宏例外. 比如我写了下面一段宏,名为insert_table. 执行这段代码,调试器会在第23行停下来. ABAP调试器里有个工具可以用于宏的调试, ...

  7. [转]查找问题的利器 - Git Bisect

    转自:http://gitbook.liuhui998.com/5_4.html 假设你在项目的'2.6.18'版上面工作, 但是你当前的代码(master)崩溃(crash)了. 有时解决这种问题的 ...

  8. Wannafly挑战赛1,2

    做了好久了,今天大佬讲题,好厉害,弱鸡只会几道水题. Treepath 给定一棵n个点的树,问其中有多少条长度为偶数的路径.路径的长度为经过的边的条数.x到y与y到x被视为同一条路径.路径的起点与终点 ...

  9. 牛客国庆集训派对Day2 F、平衡二叉树 【构造+记忆化搜索】

    任意门:https://www.nowcoder.com/acm/contest/202/F 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 1048576K,其他语言2097152K6 ...

  10. AQS(一) 对CLH队列的增强

    基本概念 AQS(AbstractQueuedSynchronizer),顾名思义,是一个抽象的队列同步器. 它的队列是先进先出(FIFO)的等待队列 基于这个队列,AQS提供了一个实现阻塞锁的机制 ...