Well, I´m doing and ls program in C and I have a problem. I have to show the file permissions with this format:
drwxr-xr-x
But I get the permissions as a int because this return me this value as a int:
lstat(file->d_name, &info);
printf("%d \n", info.st_mode);
This shows for exemple: $ 33188
How can I convert the int permissions to drwxr-xr-x?
Thanks very much.
Regards.
The mode of a file is a bitset of permissions and file type field. These flags are defined in
man stat.h.You can extract the information from the mode like this:
etc. for group, others.