util.file.contents
Shared
Retrieves the contents of a specified directory path
Syntax
local contents = util.file.contents(
path,
directory_search = false
)Prefix the path with :resourcename to access directories from another running resource.
- Local path — resolves relative to the current resource's directory.
- Cross-resource path — prefix with
:resourcenameto resolve relative to another running resource's directory. - Example —
:resource_a/files/imagesaccesses thefiles/imagesdirectory insideresource_a.
Parameters
| Type | Name | Description |
|---|---|---|
string | path | Directory path to check for contents |
bool | directory_search | Indicates whether to search only for directories, ignoring files |
Returns
| Type | Name | Description |
|---|---|---|
table | bool | contents | Contents of the specified directory on successful execution, false otherwise |
Examples
core.engine.print("info", "File contents:")
core.engine.iprint(util.file.contents("files/images"))core.engine.print("info", "File contents:")
core.engine.iprint(util.file.contents(":resource_a/files/images"))