Skip to content

Files

Limited to the Lexis directory

Functions

Return Type Name Description
bool files.exists(string path) Whether the file exists
bool files.remove(string path) Deletes a file
file files.open(string path, table? options = { create_if_not_exists = false, append = false }) Opens a file for reading/writing

Types

file

Property Name Description
bool good Whether the file is open
string text Read/write as text
nlohmann_json json Read/write as nlohmann_json

Examples

-- Checking if a file exists
local path = 'file.txt'
if files.exists(path) then
  print('File exists')
end

-- Opening a file
local file = file.open(path, { create_if_not_exists = true })
if file.good then
  file.text = 'Hello, world!'
  print(file.text)
end