--
directory=mg.request_info.uri
-- Listing is generated via ls -l
lsfd = io.popen("/bin/ls -lthL " .. mg.document_root .. directory)
if lsfd.read then
-- skip 'total' line
lsfd:read()
listing = "
Filename
Date modified
Size
"
-- For each line
for line in lsfd:lines() do
-- Get array of words from line
words = {}
for word in string.gmatch(line, "([^%s]+)") do
words[#words + 1] = word
end
filename = words[9]
if filename ~= "index.lua" then
size = words[5]
date = words[6]
time = words[7] .. ' ' .. words[8]
listing = listing .. "