Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include "csapp.h"
  2.  
  3. int main (int argc, char **argv)
  4. {
  5. struct stat stat;
  6. char *type, *readok;
  7.  
  8. Stat(argv[1], &stat);
  9. if (S_ISREG(stat.st_mode)) /* Determine file type */
  10. type = "regular";
  11. else if (S_ISDIR(stat.st_mode))
  12. type = "directory";
  13. else
  14. type = "other";
  15. if ((stat.st_mode & S_IRUSR)) /* Check read access */
  16. readok = "yes";
  17. else
  18. readok = "no";
  19.  
  20. printf("type: %s, read: %s\n", type, readok);
  21. exit(0);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement