linux编程之stat函数
来源:互联网 发布:淘宝代销利润如何算 编辑:程序博客网 时间:2024/06/15 21:02
stat函数用来获取文件的信息,如文件大小,修改时间等
stat函数的返回值是一个结构体其名字为struct stat
struct stat {
dev_t st_dev;/* 包含这个文件的设备 ID */
ino_t st_ino;/* inode 编号 */
mode_t st_mode;/* 访问权限 */
nlink_t st_nlink;/* 硬链接数量 */
uid_t st_uid;/* 用户ID */
gid_t st_gid;/* 组ID */
dev_t st_rdev;/* 设备ID */
off_t st_size;/* 文件占用的字节数 */
blksize_t st_blksize;/* 文件系统块大小 */
blkcnt_t st_blocks;/* 文件占用了几个512字节 */
time_t st_atime;/* 最后访问时间 */
time_t st_mtime;/* 最后更改时间 */
time_t st_ctime;/* 最后状态更改时间 */}
stat函数的原型是:
intstat(const char *pathname, struct stat*buf);
第一个参数是文件的路径名,第二个输出参数用来保存返回值。执行成功后返回0,否则失败,失败后改变全局变量errno的值。
使用示例:
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
int main(int argc,char * argv[]){
struct stat st;
int f=stat(argv[1],&st);
if(f==0)
{
printf()/*打印相关参数*/
}
}
- linux编程之stat函数
- linux之stat函数解析
- linux C函数之stat函数
- linux C函数之stat函数
- linux C函数之stat函数
- linux stat函数讲解
- linux stat函数讲解
- Linux stat函数讲解
- Linux stat函数讲解
- Linux stat函数讲解
- linux stat函数讲解
- Linux stat函数讲解
- Linux stat函数讲解
- linux stat函数讲解
- linux stat 函数讲解
- linux stat函数讲解
- Linux stat函数讲解
- Linux stat函数讲解
- 大三仍是Linux系统小白的我给大家讲讲学习历程
- POJ 1410 Intersection [线段相交+点在多边形内]
- 内存对齐和位域
- 模板总结
- 快速幂取模
- linux编程之stat函数
- 《神女峰》 舒婷
- 流程控制语句
- 计算机基础问题【暑期任务】
- 《PRML》第一章 读书笔记.2
- 并查集详解 (转)
- Java实现游戏抽奖算法
- SSM整合(spingmvc,spring,mybatis)
- Java 17:Java并发编程实战1