Filesystem

appendfile

Appends content to a workspace file without replacing the existing contents.

Syntax

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

Arguments

NameTypeDescription
pathstringWorkspace-relative path to the file or folder.
contentstringText or byte string to write.

Description

Appends content to a workspace file without replacing the existing contents.

Call it with 2 parameter(s): path, content. 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 content without replacing the existing file.

local path = "workspace/examples/log.txt"

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

print(readfile(path))