cleanup, docs
This commit is contained in:
@@ -1,11 +1,26 @@
|
||||
file_pwrite
|
||||
:sig
|
||||
u64 file_pwrite(u64 h, u64 offset, String data)
|
||||
|
||||
Streaming/handle-based file I/O across the wasm host membrane. Handles are opaque u64 values returned by file_open(); 0 means open failed (including path policy denial or bounded lock timeout). Locks are automatic and lifetime-scoped: read opens take a shared lock, write/append/read-write opens take an exclusive lock, and file_close() releases it. Lock wait is bounded by UCE_FILE_LOCK_TIMEOUT_MS (default 2000ms).
|
||||
:params
|
||||
h : handle from file_open() opened for writing
|
||||
offset : absolute byte offset to write at
|
||||
data : bytes to write
|
||||
return value : number of bytes written
|
||||
|
||||
See also: file_get_contents, file_put_contents, file_append.
|
||||
:content
|
||||
Writes `data` at an absolute `offset` without moving the handle's current offset. The handle must be opened with a writable mode (`"r+"` for in-place edits).
|
||||
|
||||
:example
|
||||
u64 h = file_open("/tmp/doc-pwrite.txt", "w");
|
||||
file_write(h, "hello world");
|
||||
file_close(h);
|
||||
u64 e = file_open("/tmp/doc-pwrite.txt", "r+");
|
||||
file_pwrite(e, 6, "earth");
|
||||
file_close(e);
|
||||
print(file_get_contents("/tmp/doc-pwrite.txt"), "\n");
|
||||
|
||||
:see
|
||||
>sys
|
||||
|
||||
:example
|
||||
print("file_pwrite example\n");
|
||||
file_write
|
||||
file_pread
|
||||
file_open
|
||||
|
||||
Reference in New Issue
Block a user