[ UP ] update cgi. add display percentege bar icons.
[archserver.git] / mail / postfix / cgi / index.lua
blobd129dc00499bb7cab686fce61e5b27e4485609ed
1 #!/usr/bin/lua
2 dofile "lib.inc";
4 require "lfs"
5 function dirtree(dir)
6 assert(dir and dir ~= "", "directory parameter is missing or empty")
7 if string.sub(dir, -1) == "/" then
8 dir=string.sub(dir, 1, -2)
9 end
11 local function yieldtree(dir)
12 for entry in lfs.dir(dir) do
13 if entry ~= "." and entry ~= ".." then
14 entry=dir.."/"..entry
15 local attr=lfs.attributes(entry)
16 coroutine.yield(entry,attr)
17 if attr.mode == "directory" then
18 yieldtree(entry)
19 end
20 end
21 end
22 end
23 return coroutine.wrap(function() yieldtree(dir) end)
24 end
26 print("Content-type: text/html\n\n");
27 print("<html><body>");
29 print("vmail<p>");
31 for filename, attr in dirtree(".") do
32 print(attr.mode, filename, "<br>");
33 end
35 print("</body></html>");