It may also depend on how "standard" the desired string is whether @jasper's solution is enough for @cnuzzi. Usually, the setuid, setgid, sticky bits have some `'s'` or `'t'` substitutions for the `'x'`, and capitialized `[ST]` if one of those bits is set but the corresponding execute permission is missing. I think Unix standardization efforts were disintegrating by the time they were getting around to this level of the userspace utilities.
So, @jasper may need to use something like this (from [https://github.com/c-blake/lc/blob/master/lc.nim](https://github.com/c-blake/lc/blob/master/lc.nim) search for `proc fmtPerm`): import posix proc fmtPerm*(m: Mode, s=""): string = ## Call with ``.st_mode`` of some ``Stat`` to get rwxr-x..; ``s`` is optional ## separator string such as a space or a comma to enhance readabilty. let m = m.uint and 4095 const rwx = ["---", "--x", "-w-", "-wx", "r--", "r-x", "rw-", "rwx" ] result = rwx[(m shr 6) and 7] & s & rwx[(m shr 3) and 7] & s & rwx[m and 7] let o = s.len if (m and 0o4000) != 0 and (m and 0o100) != 0: result[2] = 's' #setuid,+x if (m and 0o4000) != 0 and (m and 0o100) == 0: result[2] = 'S' #setuid,noX if (m and 0o2000) != 0 and (m and 0o010) != 0: result[5+o] = 's' #setgid,+x if (m and 0o2000) != 0 and (m and 0o010) == 0: result[5+o] = 'S' #setgid,noX if (m and 0o1000) != 0 and (m and 0o001) != 0: result[8+o] = 't' #sticky,+x if (m and 0o1000) != 0 and (m and 0o001) == 0: result[8+o] = 'T' #sticky,noX Run I didn't see any direct code to do this formatting in `posix`, but you surely would `import posix` to get `Mode`. That code just uses the raw low 12 bits, but those are actually pretty standard.
