Chinaunix首页 | 论坛 | 博客
  • 博客访问: 63788
  • 博文数量: 41
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 10
  • 用 户 组: 普通用户
  • 注册时间: 2015-01-14 13:31
文章分类

全部博文(41)

文章存档

2015年(41)

我的朋友

分类: LINUX

2015-01-20 11:40:24

原文地址:stat函数说明 作者:tuyer

学习,,lstat,fstat
1 都是获取(普通文件,目录,管道,socket,字符,块()的。
函数原型
#include

stat(const char *restrictpathname, struct stat *restrictbuf);
提供文件名字,获取文件对应属性。
int fstat(intfiledes, struct stat *buf);
通过文件描述符获取文件对应的属性。
int lstat(const char *restrictpathname, struct stat *restrictbuf);
连接文件描述命,获取文件属性。
2 文件对应的属性
struct stat {
        mode_t     st_mode;       //文件对应的模式,文件,目录等
        ino_t      st_ino;       //inode节点号
        dev_t      st_dev;        //设备号码
        dev_t      st_rdev;       //特殊设备号码
        nlink_t    st_nlink;      //文件的连接数
        uid_t      st_uid;        //文件所有者
        gid_t      st_gid;        //文件所有者对应的组
        off_t      st_size;       //普通文件,对应的文件字节数
        time_t     st_atime;      //文件最后被访问的时间
        time_t     st_mtime;      //文件内容最后被修改的时间
        time_t     st_ctime;      //文件状态改变时间
        blksize_t st_blksize;    //文件内容对应的块大小
        blkcnt_t   st_blocks;     //伟建内容对应的块数量
      };
可以通过上面提供的函数,返回一个结构体,保存着文件的信息。
阅读(579) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~