l = require "luxio"

dirp = l.opendir(arg[1] or ".")

if l.DT_UNKNOWN then
   types = {
      [l.DT_UNKNOWN] = "?",
      [l.DT_FIFO] = "|",
      [l.DT_CHR] = "c",
      [l.DT_DIR] = "d",
      [l.DT_BLK] = "b",
      [l.DT_REG] = "r",
      [l.DT_LNK] = "l",
      [l.DT_SOCK] = "s"
   }
else
   types = {}
end

repeat
   e, i = l.readdir(dirp)
   if e == 0 then print(types[i.d_type] or "?", i.d_ino, i.d_name) end
until i == nil
