Just check that set for each permission and add the corresponding character, it 
should map 1-1.
    
    
    proc posixRepr(file: string): string =
      let info = getFileInfo(file, followSymlink = false)
      result.add([pcFile: '-', 'l', pcDir: 'd', 'l'][info.kind])
      for i, fp in [fpUserRead, fpUserWrite, fpUserExec, fpGroupRead, 
fpGroupWrite,
                    fpGroupExec, fpOthersRead, fpOthersWrite, fpOthersExec]:
        result.add(if fp in info.permissions: "rwx"[i mod 3] else: '-')
    
    
    Run

Reply via email to