def write_atomic

cswap-bend-cli@0.1.0.0 · fs/write.bend:83

import cswap-bend-cli@0.1.0.0/fs/write.bend as Write
import Base
import cswap-bend-cli@0.1.0.0/fs.bend as Fs

83# Write `data` to a sibling temp file, give it `mode` (an octal string such
84# as "600") while it is still empty, then rename it over `path`. The
85# secret is never on disk at another mode, and readers see the old file or
86# the new one, never half of it.
87def write_atomic(path: String, data: String, mode: String) -> IO(Fs.Res(Unit)):
88  IO.bind(Fs.Res(U32), Fs.Res(Unit), IO.random_u32(), r => publish.tmp(r, path, data, mode))

Uses (8)

Used by (7)