Donut Team is a labor of love, built and maintained by a small group of passionate developers. We invest our own time and resources to offer our tools, mods, and web services completely free of charge.

We don't run ads, and we will never sell your data - period.

If you've enjoyed anything we've created, please consider supporting our work with a one-time or monthly donation via our Ko-fi page . Every contribution helps us continue building great experiences for the community.

Dismiss
  • Modding Tools
  • Lucas' Simpsons Hit & Run Mod Launcher
  • Hacks
  • Mod Requirable Hacks
  • Custom Files
  • Lua Functions
  • File System Functions

DirectoryGetEntries

Available since Version 1.7.

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 true to 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.