linux文件操作篇 (三) 文件状态和操作属性
#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文件操作篇 (三) 文件状态和操作属性的更多相关文章
- Util应用程序框架公共操作类(三):数据类型转换公共操作类(扩展篇)
上一篇以TDD方式介绍了数据类型转换公共操作类的开发,并提供了单元测试和实现代码,本文将演示通过扩展方法来增强公共操作类,以便调用时更加简化. 下面以字符串转换为List<Guid>为例进 ...
- python学习笔记三 文件操作(基础篇)
文件操作 打开文件 open(name[,mode[,buffering]]) open函数使用一个文件名作为强制参数,然后返回一个文件对象.[python 3.5 把file()删除掉] w ...
- Python【第三篇】文件操作、字符编码
一.文件操作 文件操作分为三个步骤:文件打开.操作文件.关闭文件,但是,我们可以用with来管理文件操作,这样就不需要手动来关闭文件. 实现原理: import contextlib @context ...
- Python之路【第三篇】:文件操作
一.文件操作步骤 打开文件,得到文件句柄并赋值给一个变量 通过句柄对文件进行操作 关闭文件 歌名:<大火> 演唱:李佳薇 作词:姚若龙 作曲:马奕强 歌词: 有座巨大的停了的时钟 倾倒在赶 ...
- linux文件IO操作篇 (二) 缓冲文件
2. 缓冲文件操作 //规模较大 实时性低的文件 //当数据长度快要超过缓冲区的范围时,或者时间周期达到时,数据才被送往指定位置 //需要使用FILE * 作为文件标识符 //stdin 标准输入 / ...
- linux文件IO操作篇 (一) 非缓冲文件
文件IO操作分为 2 种 非缓冲文件IO 和 缓冲文件IO 它们的接口区别是 非缓冲 open() close() read() write() 缓冲 fopen() fclose() fread() ...
- linux文件操作篇 (四) 目录操作
#include <sys/stat.h>#include <unistd.h>#include <dirent.h> //创建文件夹 路径 掩码 int mkdi ...
- linux文件操作篇 (二) 打开和关闭文件
2.1 打开文件和关闭文件 #include <sys/types.h>#include <sys/stat.h>#include <fcntl.h> 头文件 i ...
- Linux(三) - 文件操作相关命令
Ctl-A 光标移动到行首 Ctl-C 终止命令 Ctl-D 注销登录 Ctl-E 光标移动到行尾 Ctl-U 删除光标到行首的所有字符,在某些设置下,删除全行 Ctl-W 删除当前光标到前边的最近一 ...
随机推荐
- Hive的UDF(用户自定义函数)开发
当 Hive 提供的内置函数无法满足你的业务处理需要时,此时就可以考虑使用用户自定义函数(UDF:user-defined function). 测试各种内置函数的快捷方法: 创建一个 dual 表 ...
- 解决Image在canvas以及audio、video在AudioContext下跨域问题
媒体元素嘛,在对应的标签或对象上加上 crossOrigin = 'anonymous' 即可. 例如 Image 在canvas 上绘制时会跨域: <img crossOrigin=" ...
- 【Leetcode】【Easy】Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the l ...
- SASS初体验
SASS初体验 标签(空格分隔): sass scss css 1. 编译环境 需要安装Ruby,之后需要打开Start Command Prompt with Ruby运行 gem install ...
- YouTube 1080P高清视频下载方法
在国内在线视频网站还停留在1080P蓝光的时候,YouTube早已经支持4K和8K分辨率的极清视频.虽然4K和8K的清晰度比1080P高了许多档次,但是大部分人的电脑播放4K视频还是很卡的,所以目前来 ...
- Python语言程序设计基础(1)—— 程序设计基本方法
Everybody in this country should learn how to program a computer,because it teaches you how to think ...
- NEUACM1132: Renew MST Quickly 增量最小生成树
题目链接:http://acm.neu.edu.cn/hustoj/problem.php?id=1132 和UVa11354很类似 题意: 原先有一棵树,每次加一条边,看最小生成树大小: 这个和增量 ...
- 【[SCOI2010]生成字符串】
\(n=m\)时候经典的卡特兰 那\(n!=m\)呢,还是按照卡特兰的方式来推 首先总情况数就是\(\binom{n+m}{n}\),在\(n+m\)个里选择\(n\)个\(1\) 显然有不合法的情况 ...
- jmeter报"msg":"Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported"的解决方法
1.报"msg":"Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supporte ...
- jstl有什么优势(简单介绍)
简单介绍 JSTL是一个不断完善的开放源代码的JSP标签库,是由apache的jakarta小组来维护的.JSTL只能运行在支持JSP1.2和Servlet2.3规范的容器上,如tomcat 4.x. ...