Difference between revisions of "Lua:getDirectoryList"
Jump to navigation
Jump to search
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| − | getDirectoryList(Path | + | [[Category:Lua]] |
| + | {{CodeBox|'''function''' getDirectoryList(''Path'', ''SearchSubDirs'') ''':''' table}} | ||
| + | |||
| + | Returns an indexed table containing directory names. | ||
| + | |||
| + | The function lists directories inside the given path. When SearchSubDirs is true, subdirectories are searched recursively. | ||
| + | |||
| + | ===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 in. | ||
| + | |- | ||
| + | |SearchSubDirs | ||
| + | |Boolean (optional) | ||
| + | |If true, subdirectories are searched recursively. | ||
| + | |} | ||
| + | |||
| + | ===Returns=== | ||
| + | Table — An indexed table containing directory names. | ||
| + | |||
| + | ===Examples=== | ||
<pre> | <pre> | ||
| − | + | local directories = getDirectoryList("C:\\\\Temp") | |
| − | + | ||
| + | for i = 1, #directories do | ||
| + | print(directories[i]) | ||
| + | end | ||
</pre> | </pre> | ||
| − | + | ||
<pre> | <pre> | ||
| − | + | local directories = getDirectoryList("C:\\\\Temp", true) | |
| − | + | ||
| − | + | print("Directories found: " .. tostring(#directories)) | |
| − | + | ||
| − | + | for i = 1, #directories do | |
| − | + | print(directories[i]) | |
| − | + | end | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
</pre> | </pre> | ||
| + | |||
| + | <pre> | ||
| + | local path = getTempFolder() | ||
| + | local directories = getDirectoryList(path) | ||
| + | |||
| + | for i, directory in ipairs(directories) do | ||
| + | print(directory) | ||
| + | end | ||
| + | </pre> | ||
| + | |||
| + | {{LuaSeeAlso}} | ||
Latest revision as of 00:49, 25 June 2026
Returns an indexed table containing directory names.
The function lists directories inside the given path. When SearchSubDirs is true, subdirectories are searched recursively.
Function Parameters[edit]
| Parameter | Type | Description |
|---|---|---|
| Path | String | The directory path to search in. |
| SearchSubDirs | Boolean (optional) | If true, subdirectories are searched recursively. |
Returns[edit]
Table — An indexed table containing directory names.
Examples[edit]
local directories = getDirectoryList("C:\\\\Temp")
for i = 1, #directories do
print(directories[i])
end
local directories = getDirectoryList("C:\\\\Temp", true)
print("Directories found: " .. tostring(#directories))
for i = 1, #directories do
print(directories[i])
end
local path = getTempFolder() local directories = getDirectoryList(path) for i, directory in ipairs(directories) do print(directory) end