Volt

isfolder

Checks if a path points to a folder.

Syntax

isfolder(path: string) -> boolean

Parameters

ParameterTypeDescription
pathstringThe path to check

Returns

TypeDescription
booleantrue 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", "{}")

On this page