erdos/src/fs.lua

32 lines
662 B
Lua

return function()
local lfs = love.filesystem
function fsLs(path)
return lfs.getDirectoryItems(path)
end
function fsHas(file)
if lfs.getInfo
then return not not lfs.getInfo(file) end
return lfs.exists(file)
end
function fsInfo(file)
if lfs.getInfo
then return lfs.getInfo(file)
end
if not fsHas(file)
then return end
local info = {}
if lfs.isFile(file) then info.type = 'file'
elseif lfs.isDirectory(file) then info.type = 'directory'
elseif lfs.isSymlink(file) then info.type = 'symlink'
else info.type = 'other' end
info.size = lfs.getSize(file)
info.modtime = lfs.getLastModified(file)
return info
end
end