Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <unistd.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <iostream>
- using namespace std;
- int main(int argc, char *argv[]){
- struct stat sb;
- if(stat(argv[1], &sb) == -1){
- printf("\nError in opening file or directory.\n");
- return 0;
- }
- if (S_ISREG(sb.st_mode)){
- printf("\nRegular file\n");
- }
- if (S_ISDIR(sb.st_mode)){
- printf("\nDirectory\n");
- }
- cout<<"Test name: "<<argv[1]<<endl;
- cout<<"ID of device containing file: "<<sb.st_dev<<endl;
- cout<<"inode number: "<<sb.st_ino<<endl;
- cout<<"User ID of owner: "<<sb.st_uid<<endl;
- cout<<"File size: "<<sb.st_size<<endl;
- cout<<"Time of last access: "<<sb.st_atime<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement