-- Author: Luke
-- Date: 2010-04-10
- Code: Select all
local root_dir = "c:/temp" --physical path for storing temporary uploaded files
local timeout = 3600*3 --clean up uploaded files older than 3 hours
local removefiles = {}
local now = os.time()
if c_GetFileDir(root_dir) ~= nil then
for isdir,filename in c_GetFileDir(root_dir) do
if isdir == false and filename ~= nil and filename ~= "." and filename ~= ".." then
local filepath = root_dir.."/"..filename
if c_FileExist(filepath) then
if c_GetFileTime(filepath) + timeout < now then
table.insert(removefiles, filename)
end
end
end
end
end
for _,filename in ipairs(removefiles) do
c_RemoveFileDir(root_dir.."/"..filename)
end
