isfolder
Checks if a path points to a folder.
Syntax
isfolder(path: string) -> booleanParameters
| Parameter | Type | Description |
|---|---|---|
path | string | The path to check |
Returns
| Type | Description |
|---|---|
boolean | true if the path is a folder |
Description
isfolder returns whether the specified path exists and is a folder (not a file).
Example
makefolder("myfolder")
writefile("myfile.txt", "Hello")
print(isfolder("myfolder")) -- true
print(isfolder("myfile.txt")) -- false (it's a file)
print(isfolder("nonexistent")) -- false (doesn't exist)Ensuring Folder Exists
local function ensureFolder(path)
if not isfolder(path) then
makefolder(path)
end
end
ensureFolder("data")
ensureFolder("data/saves")
writefile("data/saves/save1.json", "{}")Related Functions
isfile- Check if path is a filemakefolder- Create a folder