Untitled
#include<stdio.h> #include<unistd.h> #include<fcntl.h> #include<sys/stat.h> main(int argc,char *argv[]) { struct stat buf; int fd,n,i=1; while(i<argc) { fd=open(argv[i],O_RDONLY); fd=fstat(fd,&buf); printf("The information of the file is:%s\n",argv[i]); if(S_ISREG(buf.st_mode)) printf("file is regular\n"); elseif(S_ISDIR(buf.st_mode)) printf("it is a directory\n"); else printf("Not a specific file type\n"); printf("Number of links:%d\n",buf.st_nlink); printf("Type and permission:%o\n",buf.st_mode); printf("Time of last access:%s\n",ctime(buf.st_mtime)); i++; } }
Leave a Comment