Vital.sandbox
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 :resourcename to resolve relative to another running resource's directory
  • Example:resource_a/files/images accesses the files/images directory inside resource_a

Parameters

TypeNameDescription
stringpathDirectory path to check for contents
booldirectory_searchIndicates whether to search only for directories, ignoring files

Returns

TypeNameDescription
table / boolcontentsContents of the specified directory on successful execution, or false on failure

Examples

List the contents of a directory within the current resource
engine.print("info", "File contents:")
engine.iprint(file.contents("files/images"))
List the contents of a directory from another running resource
engine.print("info", "File contents:")
engine.iprint(file.contents(":resource_a/files/images"))

On this page