summaryrefslogtreecommitdiff
path: root/tests/test-dirent.lua
blob: 5f5409910a7dfc9ba99f2b232af40e792eba1a44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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