语法
isfile(path: string): boolean参数
| 名称 | 类型 | 描述 |
|---|---|---|
path | string | 文件或文件夹的工作空间相对路径。 |
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
isFile | boolean | 当路径存在并且是文件时为 true。 |
说明
检查工作空间路径是否存在并指向文件。
使用 1 个参数调用: path。参数表会说明哪些值必填,哪些值只用于细化行为。
返回 isFile (boolean)。使用返回表区分成功值、nil 结果和可恢复错误。
示例
检查工作空间路径是否指向常规文件。
local path = "workspace/examples/config.json"
if isfile(path) then
print("File exists")
else
print("File does not exist")
end