Difference between revisions of "Lua:getDirectoryList"
Jump to navigation
Jump to search
m |
|||
| Line 1: | Line 1: | ||
| − | getDirectoryList(Path | + | [[Category:Lua]] |
| + | '''function''' getDirectoryList(''Path'', [''SearchSubDirs'']) ''':''' Table | ||
| + | |||
| + | Returns an indexed table containing the names of directories in the specified path. | ||
| + | |||
| + | ===Function Parameters=== | ||
| + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" | ||
| + | !align="left"|Parameter | ||
| + | !align="left"|Type | ||
| + | !style="width: 80%;background-color:white;" align="left"|Description | ||
| + | |- | ||
| + | |Path | ||
| + | |String | ||
| + | |The directory path to search. | ||
| + | |- | ||
| + | |SearchSubDirs | ||
| + | |Boolean (optional) | ||
| + | |If true, searches subdirectories recursively. Default is false. | ||
| + | |} | ||
| + | |||
| + | ===Returns=== | ||
| + | Table — An indexed table with the names of directories found. | ||
| + | |||
| + | ===Examples=== | ||
<pre> | <pre> | ||
| − | + | local dirs = getDirectoryList(getAutorunPath()) | |
| − | + | for i, name in ipairs(dirs) do | |
| − | + | print(name) | |
| − | + | end | |
| − | + | ||
| − | + | -- Search recursively | |
| − | + | local allDirs = getDirectoryList(getAutorunPath(), true) | |
| − | + | for i, name in ipairs(allDirs) do | |
| − | + | print(name) | |
| − | + | end | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
</pre> | </pre> | ||
| + | |||
| + | == See also == | ||
| + | * [[Lua:getFileList|getFileList]] | ||
| + | * [[Lua:getFileList|getFileList]] | ||
Revision as of 19:11, 11 July 2025
function getDirectoryList(Path, [SearchSubDirs]) : Table
Returns an indexed table containing the names of directories in the specified path.
Function Parameters
| Parameter | Type | Description |
|---|---|---|
| Path | String | The directory path to search. |
| SearchSubDirs | Boolean (optional) | If true, searches subdirectories recursively. Default is false. |
Returns
Table — An indexed table with the names of directories found.
Examples
local dirs = getDirectoryList(getAutorunPath()) for i, name in ipairs(dirs) do print(name) end -- Search recursively local allDirs = getDirectoryList(getAutorunPath(), true) for i, name in ipairs(allDirs) do print(name) end