File
file.contents
Shared
Retrieves the contents of a specified directory path
Syntax
local contents = 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, or false on failure |
Examples
engine.print("info", "File contents:")
engine.iprint(file.contents("files/images"))engine.print("info", "File contents:")
engine.iprint(file.contents(":resource_a/files/images"))