#include <sys/stat.h> #include <unistd.h>
int stat(const char * file_name, struct stat *buf);
struct stat
{
dev_t st_dev; //device 文件的设备编号
ino_t st_ino; //inode 文件的i-node
mode_t st_mode; //protection 文件的类型和存取的权限
nlink_t st_nlink; //number of hard links 连到该文件的硬连接数目, 刚建立的文件值为1.
uid_t st_uid; //user ID of owner 文件所有者的用户识别码
gid_t st_gid; //group ID of owner 文件所有者的组识别码
dev_t st_rdev; //device type 若此文件为装置设备文件, 则为其设备编号
off_t st_size; //total size, in bytes 文件大小, 以字节计算
unsigned long st_blksize; //blocksize for filesystem I/O 文件系统的I/O 缓冲区大小.
unsigned long st_blocks; //number of blocks allocated 占用文件区块的个数, 每一区块大小为512 个字节.
time_t st_atime; //time of lastaccess 文件最近一次被存取或被执行的时间, 一般只有在用mknod、utime、read、write 与tructate 时改变.
time_t st_mtime; //time of last modification 文件最后一次被修改的时间, 一般只有在用mknod、utime 和write 时才会改变
time_t st_ctime; //time of last change i-node 最近一次被更改的时间, 此参数会在文件所有者、组、权限被更改时更新
};
#include <sys/stat.h>
#include <unistd.h>
main()
{
struct stat buf;
stat("/etc/passwd", &buf);
printf("/etc/passwd file size = %d \n", buf.st_size);
}
/etc/passwd file size = 705
#include <sys/stat.h> #include <unistd.h>
int fstat(int fildes, struct stat *buf);
#include <sys/stat.h>
#include <unistd.h>
#include <fcntk.h>
main()
{
struct stat buf;
int fd;
fd = open("/etc/passwd", O_RDONLY);
fstat(fd, &buf);
printf("/etc/passwd file size +%d\n ", buf.st_size);
}
/etc/passwd file size = 705
#include <sys/stat.h> #include <unistd.h>
int lstat (const char * file_name, struct stat * buf);
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有