请问如何用c语言来获取一份文件的大小,权限等属性?
用文件流与文件建立关联之后怎样实现阿?
[问题]请问如何用c语言来获取一份文件的大小,权限等属性?
-
- 帖子: 49
- 注册时间: 2007-10-06 11:02
- 来自: 广东佛山
- iblicf
- 帖子: 3766
- 注册时间: 2007-01-15 17:15
代码: 全选
man fstat
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 filesystem I/O */
blkcnt_t st_blocks; /* number of 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 */
};
-
- 帖子: 49
- 注册时间: 2007-10-06 11:02
- 来自: 广东佛山
-
- 帖子: 49
- 注册时间: 2007-10-06 11:02
- 来自: 广东佛山
-
- 帖子: 49
- 注册时间: 2007-10-06 11:02
- 来自: 广东佛山
iblicf 写了:参见 APUE代码: 全选
man fstat 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 filesystem I/O */ blkcnt_t st_blocks; /* number of 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 */ };
你好 文件大小通过printf()能正确输出
但文件权限该怎样输出才能显示 -rwxr--r--类似的模式