safe

package
v0.1.0-cvefix.2 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

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