filemode.bmx 500 B

12345678910111213141516171819202122232425
  1. ' filemode.bmx
  2. SuperStrict
  3. ' the following function converts the file mode to
  4. ' the standard unix permission bits string
  5. Function Permissions:String(mode:Int)
  6. Local testbit:Int, pos:Int
  7. Local p:String = "rwxrwxrwx"
  8. testbit = %100000000
  9. pos = 1
  10. Local res:String
  11. While (testbit)
  12. If mode & testbit
  13. res :+ Mid(p, pos, 1)
  14. Else
  15. res :+ "-"
  16. EndIf
  17. testbit = testbit Shr 1
  18. pos :+ 1
  19. Wend
  20. Return res
  21. End Function
  22. Print Permissions(FileMode("filemode.bmx"))