Syntax
isfile(path: string): booleanArguments
| Name | Type | Description |
|---|---|---|
path | string | Path resolved inside the workspace after separator normalization and workspace-boundary checks. Invalid or outside-workspace paths error before a boolean is returned. |
Returns
| Name | Type | Description |
|---|---|---|
isFile | boolean | True only when the resolved path exists and is a regular file; folders and missing paths return false. |
Description
Returns whether a path resolved inside the workspace exists and is a regular 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 resolves to an existing regular file.
local folderPath = "examples"
local filePath = "examples/config.json"
makefolder(folderPath)
writefile(filePath, "{}")
print(isfile(filePath))
print(isfile(folderPath))
print(isfile("examples/missing.json"))