Advertisement
Guest User

Untitled

a guest
Mar 1st, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <sys/types.h>
  2. #include <sys/stat.h>
  3. #include <unistd.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <iostream>
  7.  
  8. using namespace std;
  9.  
  10. int main(int argc, char *argv[]){
  11. struct stat sb;
  12.  
  13. if(stat(argv[1], &sb) == -1){
  14. printf("\nError in opening file or directory.\n");
  15. return 0;
  16. }
  17.  
  18. if (S_ISREG(sb.st_mode)){
  19. printf("\nRegular file\n");
  20. }
  21.  
  22. if (S_ISDIR(sb.st_mode)){
  23. printf("\nDirectory\n");
  24. }
  25.  
  26. cout<<"Test name: "<<argv[1]<<endl;
  27. cout<<"ID of device containing file: "<<sb.st_dev<<endl;
  28. cout<<"inode number: "<<sb.st_ino<<endl;
  29. cout<<"User ID of owner: "<<sb.st_uid<<endl;
  30. cout<<"File size: "<<sb.st_size<<endl;
  31. cout<<"Time of last access: "<<sb.st_atime<<endl;
  32.  
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement