(20)--3.5 文件IO基本操作四.ppt

  1. 1、本文档共9页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
文件IO基本操作四 stat( ) 1. stat命令 stat 文件名查看文件属性信息 2. 函数stat()#include sys/types.h#include sys/stat.h#include unistd.h?int stat(const char *path, struct stat *buf);int fstat(int fd, struct stat *buf);int lstat(const char *path, struct stat *buf);(1)函数原型 2. 函数stat()struct stat { dev_t???? st_dev;???? /* ID of device containing file */ ino_t???? st_ino;???? /* inode number */ mode_t??? st_mode;??? /* protection */ nlink_t?? st_nlink;?? /* number of hard links */ uid_t???? st_uid;???? /* user ID of owner */ gid_t???? st_gid;???? /* group ID of owner */ dev_t???? st_rdev;??? /* device ID (if special file) */ off_t???? st_size;??? /* total size, in bytes */ blksize_t st_blksize; /* blocksize for file system I/O */ blkcnt_t? st_blocks;? /* number of 512B blocks allocated */ time_t??? st_atime;?? /* time of last access */ time_t??? st_mtime;?? /* time of last modification */ time_t??? st_ctime;?? /* time of last status change */};(2)struct stat结构体 2. 函数stat()……memset(buf, 0, sizeof(buf));ret = stat(PATHNAME, buf); if (ret 0) { perror(stat error); exit(-1); }printf(inode = %d.\n, buf.st_ino);printf(size = %d bytes.\n, buf.st_size);printf(st_blksize = %d.\n, buf.st_blksize);printf(st_blocks = %d.\n, buf.st_blocks); ……示例1(2)struct stat结构体 2. 函数stat()struct stat { dev_t???? st_dev;???? /* ID of device containing file */ ino_t???? st_ino;???? /* inode number */ mode_t??? st_mode;??? /* protection */ nlink_t?? st_nlink;?? /* number of hard links */ uid_t???? st_uid;???? /* user ID of owner */ gid_t???? st_gid;???? /* group ID of owner */ dev_t???? st_rdev;??? /* device ID (if special file) */ off_t???? st_size;??? /* total size, in bytes */ blksize_t st_blksize; /* blocksize for file system I/O */ blkcnt_t? st_blocks;? /* number of 512B blocks allocated */ time_t??? st_atime;?? /* time of last access */ time_t??? st_mtime;?? /* time of last modification */ time_t??? st_ctime;?? /* time of last status change */};(2)struct stat结构体 2. 函数stat() …… re

文档评论(0)

177****2883 + 关注
实名认证
内容提供者

热爱教育,专注于教育领域创作与分享,让我们共同进步。

1亿VIP精品文档

相关文档