(deps: Pick<FsWriteDeps, "rename" | "write_text_file"> & Partial<FsRemoveDeps>, path: string, content: string, options?: WriteFileAtomicOptions | undefined): Promise<...> import {write_file_atomic} from '@fuzdev/fuz_app/runtime/fs.js'; Write a file atomically via temp file + rename.
Writes to a unique .{name}.tmp.{pid}.{counter} sibling with exclusive
create (O_EXCL), then renames over path so readers either see the old
contents or the full new contents — never a partial write. The unique name
+ exclusive create are load-bearing for secret files: a fixed temp name
would let a crash-leftover temp be reopened O_TRUNC with its old
(possibly permissive) mode — mode only applies at creation — and the
rename would publish that stale inode. Twin of the Rust spine's
fuz_sys::secure_file::write_secure_file naming scheme.
deps
write capabilities; pass remove too for best-effort temp cleanup on failure
Pick<FsWriteDeps, "write_text_file" | "rename"> & Partial<FsRemoveDeps>path
destination path
stringcontent
full file content
stringoptions?
optional mode applied at creation
returns
Promise<void>
throws
Error- if `write_text_file` or `rename` rejects (permissions, disk full, cross-device rename, etc.)
mutates
filesystem— creates the unique temp file then renames it to `path`