File systemReferenceNew · 0.744
appendfileasync
Append bytes to a local file asynchronously.
Details#
Adds the supplied bytes at the end of a workspace file, preserving its existing contents. Creates the file if it does not exist. No separator or newline is inserted automatically, and parent directories must already exist. Check the return value because an I/O failure can occur after a partial write.
Signature#
appendfileasync(path: string, data: string): (boolean?, string?)Parameters#
| Parameter | Type | Description |
|---|---|---|
path | string | A file path inside your workspace. The parent directory must already exist for writes. |
data | string | The bytes to write; binary strings are supported. |
Returns#
On success, true. On an I/O failure, nil and an error string. Invalid arguments or paths raise an error.
Examples#
Local example
local ok, err = appendfileasync("notes.txt", "Another local note\n")
if not ok then
warn(err)
endNotes#
- The call yields until the operation finishes, then returns its result. It does not return a promise or take a callback.
- Invalid argument types and rejected paths raise an error. A file I/O failure instead returns nil and an error string; check both results.