#include<unistd.h>
#include<fcntl.h>
#include<iostream>
#include<errno.h>
#include<sys/stat.h>
using namespace std;
int main()
{
int fileDes=open("rx.txt",O_CREAT|O_RDWR,0666);
if(fileDes==-1)
{
cout<<"open file error :"<<errno<<endl;
return 0;
}
struct stat fileAtt;
fstat(fileDes,&fileAtt);//we need the stat.h
cout<<"the file size is "<<fileAtt.st_size<<endl;
cout<<"the file owner is "<<fileAtt.st_uid<<endl;
cout<<"the file Device is "<<fileAtt.st_dev<<endl;
cout<<"the file inode is "<<fileAtt.st_ino<<endl;
cout<<"the file mode is"<<fileAtt.st_mode<<endl;
cout<<"the file number of hardlink is "<<fileAtt.st_nlink<<endl;
cout<<"the file gid is "<<fileAtt.st_gid<<endl;
cout<<"the file device type is "<<fileAtt.st_rdev<<endl;
cout<<"the file last access time is "<<fileAtt.st_atim.tv_nsec;
close(fileDes);
}
只是最后一步,时间的转换还没有做,今天就先到这里吧,明天再写