util.file.read
Shared
Reads the content of a specified file
Syntax
local content = util.file.read(
path
)Prefix the path with :resourcename to access files 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/data.jsonaccessesfiles/data.jsoninsideresource_a.
Parameters
| Type | Name | Description |
|---|---|---|
string | path | File path to read |
Returns
| Type | Name | Description |
|---|---|---|
string | bool | content | File's content on successful execution, false otherwise |
Examples
core.engine.print("info", "File content:", util.file.read("files/data.json"))core.engine.print("info", "File content:", util.file.read(":resource_a/files/data.json"))