Removed in LÖVE 0.9.0
It has been renamed to love.filesystem.getDirectoryItems.
Returns a table with the names of files and subdirectories in the specified path. The table is not sorted in any way; the order is undefined.
If the path passed to the function exists in the game and the save directory, it will list the files and directories from both places.
files = love.filesystem.enumerate( dir )
string dirlocal dir = "" --assuming that our path is full of lovely files (it should at least contain main.lua in this case) local files = love.filesystem.enumerate(dir) for k, file in ipairs(files) do print(k .. ". " .. file) --outputs something like "1. main.lua" end
function love.load()
filesString = recursiveEnumerate("", "")
end
-- This function will return a string filetree of all files
-- in the folder and files in all subfolders
function recursiveEnumerate(folder, fileTree)
local lfs = love.filesystem
local filesTable = lfs.enumerate(folder)
for i,v in ipairs(filesTable) do
local file = folder.."/"..v
if lfs.isFile(file) then
fileTree = fileTree.."\n"..file
elseif lfs.isDirectory(file) then
fileTree = fileTree.."\n"..file.." (DIR)"
fileTree = recursiveEnumerate(file, fileTree)
end
end
return fileTree
end
function love.draw()
love.graphics.print(filesString, 0, 0)
end
© 2006–2016 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/love.filesystem.enumerate