{{newin|[[0.9.0]]|090|type=function|text=It has been renamed from [[love.filesystem.enumerate]]}}

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.

== Function ==
=== Synopsis ===
<source lang="lua">
files = love.filesystem.getDirectoryItems( dir )
</source>
=== Arguments ===
{{param|string|dir|The directory.}}
=== Returns ===
{{param|table|files|A [[sequence]] with the names of all files and subdirectories as strings.}}

== Function ==
{{newinoldin|[[0.9.1]]|091|[[0.10.0]]|100|type=variant}}
=== Synopsis ===
<source lang="lua">
files = love.filesystem.getDirectoryItems( dir, callback )
</source>
=== Arguments ===
{{param|string|dir|The directory.}}
{{param|function|callback|A function which is called for each file and folder in the directory. The filename is passed to the function as an argument.}}
=== Returns ===
{{param|table|files|A [[sequence]] with the names of all files and subdirectories as strings.}}

== Examples ==
=== Simple Example ===
<source lang="lua">
local dir = ""
--assuming that our path is full of lovely files (it should at least contain main.lua in this case)
local files = love.filesystem.getDirectoryItems(dir)
for k, file in ipairs(files) do
	print(k .. ". " .. file) --outputs something like "1. main.lua"
end
</source>
=== Recursively find and display all files and folders in a folder and its subfolders. ===
<source lang="lua">
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.getDirectoryItems(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
</source>
== See Also ==
* [[parent::love.filesystem]]
[[Category:Functions]]
{{#set:Description=Returns all the files and subdirectories in the directory.}}
== Other Languages ==
{{i18n|love.filesystem.getDirectoryItems}}