l = require "luxio"

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

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"
}

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
