Documentation
¶
Overview ¶
Package atomicfile — one canonical primitive for "write a file without leaving a half-written artifact on crash". Used by config stores, daemon state, agent identity, a2a inbox, secrets — every place where a partial write at the target path would corrupt downstream consumers.
Strategy: write to a unique temp file in the *same directory* as the target, then rename(2). Same-filesystem rename is atomic on every platform clawtool supports — readers see either the old file or the new file, never a torn intermediate.
We deliberately do not use a third-party "atomic write" library (per the project's design call): stdlib gives us the right guarantees when the temp lives in the target's directory.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteFile ¶
WriteFile writes content to path via temp+rename.
mode controls the final file permission. Pass 0 to preserve the existing file's mode (or fall back to 0o644 for a brand-new path).
The caller is responsible for any parent-directory creation — MkdirAll-and-write doubles up too often (caller already knows the scope, e.g. 0o700 for ~/.config dirs vs 0o755 for repo dirs). Use WriteFileMkdir when the parent directory may not exist.
Types ¶
This section is empty.