Calls a callback function for every file and sub-directory in the given path.
The order of these files is not predictable and should not be relied upon.
Syntax
DirectoryGetEntries( path, callback, [end_to_start] )Arguments
- path (string): The directory to iterate.
- callback (function(FileOrDirectory, IsDirectory)): A callback that will be called for each item in the directory.
- FileOrDirectory (string): The file or directory name.
- IsDirectory (boolean): Whether FileOrDirectory refers to a directory.
- This callback can return
trueto continue iteration. Returning any other value or not returning anything will end it.
- end_to_start (boolean): Makes the function iterate the directory in reverse order.
- Optional, defaults to false.
Return Values
- (boolean): Whether the callback returned true every time.
Examples
-- Print each file and whether or not it's a directory.
DirectoryGetEntries(Path, function(FileOrDirectory, IsDirectory)
print(FileOrDirectory, IsDirectory)
return true
end)Version History
Version 1.23.10
Fixed a bug where calling the DirectoryGetEntries function on / yielded no results when not using the -legacyfilesystem command line argument.
Version 1.18
Added a third argument that specifies whether or not to return the list of files and folders in reverse order.