uce/site/doc/pages/file_fsync.txt
2026-06-16 23:02:45 +00:00

21 lines
509 B
Plaintext

:sig
bool file_fsync(u64 h)
:params
h : handle from file_open() opened for writing
return value : true if the flush succeeded
:content
Flushes a handle's buffered writes to disk, so the data survives a crash or power loss. Call it before `file_close()` when durability matters (e.g. after writing a checkpoint).
:example
u64 h = file_open("/tmp/doc-fsync.txt", "w");
file_write(h, "durable");
print(file_fsync(h) ? "flushed to disk" : "fsync failed", "\n");
file_close(h);
:see
>sys
file_write
file_close