功能描述:擷取檔案(普通檔案,目錄,管道,socket,字元,塊)的屬性。
用法:
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int stat(const char *restrict pathname, struct stat *restrict buf); 提供檔案名字,擷取檔案對應屬性。
int fstat(int filedes, struct stat *buf); 通過檔案描述符,擷取檔案對應的屬性。
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; //偉建内容對應的塊數量
};
