Documentation
¶
Overview ¶
Package atomicfile replaces files whole: the content goes to a uniquely named temporary file beside the target, which is synced and renamed over it. A reader sees the old file or the new one and never a partial write, a crash leaves one of the two complete, and concurrent writers never share a temporary. WriteFileDurable also syncs the directory, so once it returns the new file survives a power cut.
Index ¶
- func IsTemporary(path, candidate string) bool
- func Write(path string, perm os.FileMode, write func(io.Writer) error) error
- func WriteFile(path string, data []byte, perm os.FileMode) error
- func WriteFileDurable(path string, data []byte, perm os.FileMode) error
- func WriteSeekable(path string, perm os.FileMode, write func(io.WriteSeeker) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTemporary ¶
IsTemporary reports whether candidate names a temporary a write of path uses, as a watcher of path's directory sees it come and go.
func Write ¶
Write replaces path with what write produces, with permissions perm. On a failure path is untouched and the temporary is removed.
func WriteFileDurable ¶
WriteFileDurable is WriteFile for data the caller reports as stored, which must outlive a power cut: the directory is synced after the rename, so the replacement is on disk when it returns. A failure of that sync is reported with path already replaced.
func WriteSeekable ¶
WriteSeekable is Write for a producer that seeks back over what it wrote, as a muxer patching its header does: write is handed the temporary itself, unbuffered.
Types ¶
This section is empty.