atomic

package
v0.1.367 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compress added in v0.1.333

func Compress(filename string) (string, error)

Compress and return path to compressed file.

func CompressType added in v0.1.334

func CompressType(filename string, ty string) (string, error)

func Move added in v0.1.333

func Move(src, dst string) error

Move moves a file from a source path to a destination path This must be used across the codebase for compatibility with Docker volumes and Golang (fixes Invalid cross-device link when using os.Rename)

func WriteFile

func WriteFile(filename string, data []byte, perm os.FileMode) error

WriteFile writes the data to a temp file and atomically move if everything else succeeds.

Types

type File added in v0.1.333

type File struct {
	*os.File
	// contains filtered or unexported fields
}

File behaves like os.File, but does an atomic rename operation at Close.

func New added in v0.1.333

func New(path string, mode os.FileMode) (*File, error)

New creates a new temporary file that will replace the file at the given path when Closed.

func (*File) Abort added in v0.1.333

func (f *File) Abort() error

Abort closes the file and removes it instead of replacing the configured file. This is useful if after starting to write to the file you decide you don't want it anymore.

func (*File) Close added in v0.1.333

func (f *File) Close() error

Close the file replacing the configured file.

Jump to

Keyboard shortcuts

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