Documentation
¶
Overview ¶
Package writefile provides simple support routines for writing data to a temporary file before renaming it into place. This avoids pitfalls such as writing partial content to a file and then being interruted, or trying to write to a program that is currently being executed, etc.
This package will correctly dereference symlinks and in the case of overwriting will retain permissions from the original, underlying file.
Index ¶
Constants ¶
const ( // MaxSymlinkDeref is the maximum number of symlinks that we will // dereference before giving up. MaxSymlinkDeref = 16 )
Variables ¶
This section is empty.
Functions ¶
func Commit ¶
Commit the temporary file. This will close the file f and then rename it into place once it has been ensured the data is on disk. It will retain permissions from the original file if present.
func New ¶
New opens a file for writing. It returns the final filename which should be passed to Commit; this may differ from the passed target filename if the target is actually a symlink.
Any existing file will not be altered in any way until Commit() is called. Data will be written to a temporary file in the same directory as the target.
Types ¶
This section is empty.