UP | HOME

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
  • boolean success 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
  • boolean success
  • string|nil err

readfile(path)

yalms.fs.read_file

Read plain string from file.

Parameters
  • path (string)
Returns
  • string|nil content
  • string|nil err

readfile(path)

yalms.fs.read_file_

Read plain string from file.

Parameters
  • path (string)
Returns
  • boolean ok
  • string content

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
  • boolean success
  • string|nil err

readjson(path)

yalms.fs.read_json

Read Lua table from JSON file.

Parameters
  • path (string)
Returns
  • table|nil data
  • string|nil err

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 missing
  • content (string, optional) initial content to write
Returns
  • boolean success
  • string|nil err

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
  • boolean success
  • string|nil err