Table of Contents
Module: yalms.fs
Classes
Class: JsonUtils
@class FsUtils
Fields
encode(fun(arg: unknown))decode(fun(arg: string))
Functions
attemptcreatefile(path)
yalms.fs.attempt_create_file
Attempts to create a new file at the given path.
Parameters
path(string) The file path to create.
Returns
booleansuccess True if the file was created successfully, false otherwise.
writefile(path, data)
yalms.fs.write_file
Write plain string to file (overwrite).
Parameters
path(string)data(string)
Returns
booleansuccessstring|nilerr
readfile(path)
yalms.fs.read_file
Read plain string from file.
Parameters
path(string)
Returns
string|nilcontentstring|nilerr
readfile(path)
yalms.fs.read_file_
Read plain string from file.
Parameters
path(string)
Returns
booleanokstringcontent
safereadjson(path, defaulttbl)
yalms.fs.safe_read_json
Parameters
path(string)default_tbl(table)
Returns
table
writejson(path, tbl)
yalms.fs.write_json
Write Lua table as JSON to file.
Parameters
path(string)tbl(table)
Returns
booleansuccessstring|nilerr
readjson(path)
yalms.fs.read_json
Read Lua table from JSON file.
Parameters
path(string)
Returns
table|nildatastring|nilerr
copyfile(src, dest)
yalms.fs.copy_file
Copy file
Parameters
src(string)dest(string)
touch(path, recursive, content)
yalms.fs.touch
Ensure file exists, creating it (and parent dirs) if not. If the file exists but is empty, writes content.
Parameters
path(string)recursive(boolean, optional) create parent directories if missingcontent(string, optional) initial content to write
Returns
booleansuccessstring|nilerr
ensuredir(path)
yalms.fs.ensure_dir
Ensure directory exists, creating it (and parent dirs) if not. No-op if already present.
Parameters
path(string)
Returns
booleansuccessstring|nilerr