safe

package
v1.7.5 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: AGPL-3.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

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

File represents safe file descriptor.

func CreateFile

func CreateFile(name string) (*File, error)

CreateFile creates the named file safely from unique temporary file. The temporary file is renamed to the named file upon successful close to safeguard intermediate state in the named file. The temporary file is created in the name of the named file with suffixed unique number and prefixed "$tmpfile" string. While creating the temporary file, missing parent directories are also created. The temporary file is removed if case of any intermediate failure. Not removed temporary files can be cleaned up by identifying them using "$tmpfile" prefix string.

func (*File) Abort

func (file *File) Abort() (err error)

Abort aborts the temporary File by closing and removing the temporary file.

func (*File) Close

func (file *File) Close() (err error)

Close closes the temporary File and renames to the named file. In case of error, the temporary file is removed.

func (*File) Write

func (file *File) Write(b []byte) (n int, err error)

Write writes len(b) bytes to the temporary File. In case of error, the temporary file is removed.

Jump to

Keyboard shortcuts

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