After a quick bit of searching, I found this page:
http://www.cs.washington.edu/researc...;FileInfo.html
Look at the function modeString() and follow what it does. Here's a shortened version:
Code:
void GetRWX(mode_t i, char *buf)
{
*buf++ = (i & S_IRUSR) ? 'r' : '-';
*buf++ = (i & S_IWUSR) ? 'w' : '-';
*buf++ = (i & S_IXUSR) ? 'x' : '-';
*buf++ = (i & S_IRGRP) ? 'r' : '-';
*buf++ = (i & S_IWGRP) ? 'w' : '-';
*buf++ = (i & S_IXGRP) ? 'x' : '-';
*buf++ = (i & S_IROTH) ? 'r' : '-';
*buf++ = (i & S_IWOTH) ? 'w' : '-';
*buf++ = (i & S_IXOTH) ? 'x' : '-';
*buf = '\0';
}
/* Somewhere esle ... */
char buf[BUFSIZ];
GetRWX(buf.st_mode, buf);
puts(buf);
I don't know if this is the most efficient method or not, I have toyed in the area for sometime