Documentation
¶
Overview ¶
Package fsutil provides small filesystem helpers shared across packages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AtomicWriteFile ¶
AtomicWriteFile writes data to path using a write-to-temp-then-rename pattern in path's directory: readers see either the old content or the new one, never a half-written file, and the data and the rename are flushed to disk before it returns, so a crash or power loss leaves one of the two versions in place.
path is the destination file, data its full new content, and perm the mode for a newly created file. A path that is a symlink is written through to its target, keeping the link. An existing file keeps its permission bits; perm only applies to a newly created file, and is applied exactly (not masked by the umask). Missing parent directories are created private to the user (0700).
It returns an error when the path cannot be resolved, the directory or temporary file cannot be created, or writing, syncing, closing, chmod or renaming fails; the temporary file is removed in every failure case. A failure to sync the directory after the rename is ignored.
Types ¶
This section is empty.