file_pwrite
host callCapy
function file_pwrite(handle : u64, offset : u64, data : string) u64
Description
file_pwrite writes bytes at an absolute byte offset. It does not change the handle position.
If the offset or complete write range exceeds the system's signed file-offset range, the call returns zero without writing. It does not clamp the offset or wrap to another position.
Parameters
handle : writable handle returned by file_open
offset : absolute byte offset
data : text to write
Return Values
The number of bytes written.
Example
Capy
var handle := file_open("/tmp/doc-pwrite.txt", "w")
file_write(handle, "hello world")
file_close(handle)
var editor := file_open("/tmp/doc-pwrite.txt", "r+")
file_pwrite(editor, 6, "earth")
file_close(editor)
print(file_get_contents("/tmp/doc-pwrite.txt").value ?? "", "\n")
Output
hello earth