Volt

isfile

Checks if a path points to a file.

Syntax

isfile(path: string) -> boolean

Parameters

ParameterTypeDescription
pathstringThe path to check

Returns

TypeDescription
booleantrue if the path is a file

Description

isfile returns whether the specified path exists and is a file (not a folder).

Example

writefile("test.txt", "Hello")
makefolder("testfolder")

print(isfile("test.txt"))     -- true
print(isfile("testfolder"))   -- false (it's a folder)
print(isfile("nonexistent"))  -- false (doesn't exist)

Safe File Reading

local function safeRead(path)
    if isfile(path) then
        return readfile(path)
    end
    return nil
end

local content = safeRead("config.json")
if content then
    print("Config loaded")
else
    print("Config not found")
end

On this page