Filesystem

appendfile

Appends raw Lua string bytes to a workspace file using binary append mode.

Syntax

appendfile(path: string, data: string)
Aliases appendfileasync

Arguments

NameTypeDescription
pathstringPath resolved inside the workspace after separator normalization and workspace-boundary checks. Empty paths, paths outside the workspace, invalid filenames, DOS device names, and blocked extensions error.
datastringLua string bytes to append. No newline or other separator is added automatically.

Description

Appends raw Lua string bytes to a workspace file using binary append mode. The file may be created if its parent folder exists.

Call it with 2 parameter(s): path, data. The argument table explains which values are required and which ones only refine the behavior.

It does not return data. Treat the call as an action and handle errors around the call site when needed.

Example

Append bytes explicitly, including your own newline when you want a new line.

local path = "examples/log.txt"

writefile(path, "first entry")
appendfile(path, string.char(10) .. "second entry")

print(readfile(path))