fs

package
v1.6.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AtomicWriter

type AtomicWriter struct {
	// contains filtered or unexported fields
}

func NewAtomicWriter

func NewAtomicWriter(f string) (*AtomicWriter, error)

NewAtomicWriter returns an io.WriteCloser that will write contents to a temp file and move that temp file to the destination filename. If the destination filename already exists, this constructor will copy the file to <filename>-old, truncating that file if it already exists.

func (*AtomicWriter) Close

func (a *AtomicWriter) Close() error

Close closes the temp file handle and moves the temp file to the final destination. Multiple calls to Close will have no effect after the first success.

func (*AtomicWriter) Write

func (a *AtomicWriter) Write(p []byte) (int, error)

Write writes the buffer to the temp file. You must call Close() to complete the move from temp file to dest file. Multiple calls to Write will append to the temp file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL