Advertisement
Max13

Untitled

Nov 3rd, 2011
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. char *myls_get_fileperm(t_stat *fstat)
  2. {
  3. char *fperm;
  4.  
  5. fperm = malloc(sizeof(char) * 10);
  6. memset(fperm, '-', 9);
  7. fperm[9] = '\0';
  8. if (fstat->st_mode & S_IRWXU & S_IRUSR)
  9. fperm[0] = 'r';
  10. if (fstat->st_mode & S_IRWXU & S_IWUSR)
  11. fperm[1] = 'w';
  12. if (fstat->st_mode & S_IRWXU & S_IXUSR)
  13. fperm[2] = 'x';
  14. if (fstat->st_mode & S_IRWXG & S_IRGRP)
  15. fperm[3] = 'r';
  16. if (fstat->st_mode & S_IRWXG & S_IWGRP)
  17. fperm[4] = 'w';
  18. if (fstat->st_mode & S_IRWXG & S_IXGRP)
  19. fperm[5] = 'x';
  20. if (fstat->st_mode & S_IRWXO & S_IROTH)
  21. fperm[6] = 'r';
  22. if (fstat->st_mode & S_IRWXO & S_IWOTH)
  23. fperm[7] = 'w';
  24. if (fstat->st_mode & S_IRWXO & S_IXOTH)
  25. fperm[8] = 'x';
  26. return (fperm);
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement