Filesystem

isfolder

Returns whether a path resolved inside the workspace exists and is a directory.

Syntax

isfolder(path: string): boolean

Arguments

NameTypeDescription
pathstringPath resolved inside the workspace after separator normalization and workspace-boundary checks. Invalid or outside-workspace paths error before a boolean is returned.

Returns

NameTypeDescription
isFolderbooleanTrue only when the resolved path exists and is a directory; files and missing paths return false.

Description

Returns whether a path resolved inside the workspace exists and is a directory.

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

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

Example

Check whether a workspace path resolves to an existing directory.

local folderPath = "examples"
local filePath = "examples/config.json"

makefolder(folderPath)
writefile(filePath, "{}")

print(isfolder(folderPath))
print(isfolder(filePath))
print(isfolder("examples/missing"))