Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char *myls_get_fileperm(t_stat *fstat)
- {
- char *fperm;
- fperm = malloc(sizeof(char) * 10);
- memset(fperm, '-', 9);
- fperm[9] = '\0';
- if (fstat->st_mode & S_IRWXU & S_IRUSR)
- fperm[0] = 'r';
- if (fstat->st_mode & S_IRWXU & S_IWUSR)
- fperm[1] = 'w';
- if (fstat->st_mode & S_IRWXU & S_IXUSR)
- fperm[2] = 'x';
- if (fstat->st_mode & S_IRWXG & S_IRGRP)
- fperm[3] = 'r';
- if (fstat->st_mode & S_IRWXG & S_IWGRP)
- fperm[4] = 'w';
- if (fstat->st_mode & S_IRWXG & S_IXGRP)
- fperm[5] = 'x';
- if (fstat->st_mode & S_IRWXO & S_IROTH)
- fperm[6] = 'r';
- if (fstat->st_mode & S_IRWXO & S_IWOTH)
- fperm[7] = 'w';
- if (fstat->st_mode & S_IRWXO & S_IXOTH)
- fperm[8] = 'x';
- return (fperm);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement