Merge pull request #278 from nmav/ocserv
[project/luci.git] / libs / nixio / axTLS / www / lua / test_fs.lua
1 function link_dir (dir, base)
2 local path = base.."/"..dir
3 local mode = lfs.attributes (path).mode
4 if mode == "directory" then
5 return string.format ('<a href="%s">%s</a>',
6 cgilua.mkurlpath ("test_fs.lua", { dir = path }),
7 dir)
8 else
9 return dir
10 end
11 end
12
13 cgilua.htmlheader ()
14 cgilua.put ("<h1>Testing Filesystem library</h1>\n")
15 cgilua.put ("<table>\n")
16 cgilua.put ("<tr><td colspan=2>Testing <b>dir</b></td></tr>\n")
17 local i = 0
18 local dir = cgi.dir or "."
19 for file in lfs.dir (dir) do
20 i = i+1
21 cgilua.put ("<tr><td>"..i.."</td><td>"..link_dir(file, dir).."</td></tr>\n")
22 end
23 cgilua.put ("</table>\n")