Filesystem

isfile

Checks whether a workspace path exists and points to a file.

Syntax

isfile(path: string): boolean

Arguments

NameTypeDescription
pathstringWorkspace-relative path to the file or folder.

Returns

NameTypeDescription
isFilebooleanTrue when the path exists and is a file.

Description

Checks whether a workspace path exists and points to a file.

Call it with 1 parameter(s): path. The argument table explains which values are required and which ones only refine the behavior.

It returns isFile (boolean). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Check whether a workspace path points to a regular file.

local path = "workspace/examples/config.json"

if isfile(path) then
    print("File exists")
else
    print("File does not exist")
end