cleanup, docs
This commit is contained in:
@@ -1,11 +1,20 @@
|
||||
file_close
|
||||
:sig
|
||||
void file_close(u64 h)
|
||||
|
||||
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 returned by file_open()
|
||||
|
||||
See also: file_get_contents, file_put_contents, file_append.
|
||||
:content
|
||||
Closes a file handle and releases the lock that `file_open()` took. Always close handles you open: locks are scoped to the handle's lifetime, so a leaked handle holds its lock until the worker recycles.
|
||||
|
||||
:example
|
||||
u64 h = file_open("/tmp/doc-close.txt", "w");
|
||||
file_write(h, "done");
|
||||
file_close(h);
|
||||
print(file_exists("/tmp/doc-close.txt") ? "written and closed" : "missing", "\n");
|
||||
|
||||
:see
|
||||
>sys
|
||||
|
||||
:example
|
||||
print("file_close example\n");
|
||||
file_open
|
||||
file_write
|
||||
file_read
|
||||
|
||||
Reference in New Issue
Block a user