atomicfs

package
v0.0.0-...-685e06d Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateFile

func CreateFile(filePath string, data io.Reader) error

CreateFile safely writes the contents of data to filePath, ensuring that all data has been fsynced as well as the containing directory of the file.

Types

type File

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

File is a wrapper around an os.File instance that uses a temporary file for writes that is renamed to its final path when Close is called. The Close method will also ensure that all data from the file has been fsynced as well as the containing directory. If the temporary file cannot be renamed or fsynced on Close, it is removed.

func Create

func Create(path string) (*File, error)

Create creates a new file at a temporary path that will be renamed to the supplied path on close from a temporary file in the same directory, ensuring all data and the containing directory have been fsynced to disk.

func (*File) Close

func (a *File) Close() error

Jump to

Keyboard shortcuts

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