Syntax
listfiles(path: string): tableArguments
| Name | Type | Description |
|---|---|---|
path | string | Directory path resolved inside the workspace after separator normalization and workspace-boundary checks. Empty path or / is treated as ./; invalid or outside-workspace paths error. |
Returns
| Name | Type | Description |
|---|---|---|
paths | table | Array table of workspace-relative path strings for direct child entries. Files and folders can both be included; entries are not sorted by this function. |
Description
Returns an array table of the direct children of an existing workspace directory.
Call it with 1 parameter(s): path. The argument table explains which values are required and which ones only refine the behavior.
It returns paths (table). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Enumerate the direct child paths inside an existing workspace directory.
makefolder("examples/listing")
writefile("examples/listing/config.json", "{}")
makefolder("examples/listing/nested")
for _, path in ipairs(listfiles("examples/listing")) do
print(path)
end