#include<stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
//靠这个时间判断新文件不是很靠谱,因为
int main()
{
FILE * fp;
int fd;
struct stat buf;
fp=fopen("/home/cai/bag/test1218bag/bag_opencv_main/iamge3390.txt","r"); //C.zip in current directory, I use it as a test
fd=fileno(fp);
fstat(fd, &buf);
int size = buf.st_size; //get file size (byte)
long modify_time=buf.st_mtime; //latest modification time (seconds passed from 01/01/00:00:00 1970 UTC)
printf("file size=%d\\n",size);
printf("file last modify time=%d\\n",modify_time);
fclose(fp);
return 0;
}
网友评论