util.file.exists

Shared

Retrieves the existence of a specified file


Syntax

local valid = util.file.exists(
    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 :resourcename to resolve relative to another running resource's directory.
  • Example:resource_a/files/images/test.png accesses files/images/test.png inside resource_a.

Parameters

TypeNameDescription
stringpathFile path to verify for existence

Returns

TypeNameDescription
boolvalidSpecified file's existence

Examples

Check if a file exists within the current resource
core.engine.print("info", "File exists:", util.file.exists("files/images/test.png"))
Check if a file exists from another running resource
core.engine.print("info", "File exists:", util.file.exists(":resource_a/files/images/test.png"))

On this page