tempfile

package
v0.0.0-...-2898a4c Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const EndMode = 0666

Variables

This section is empty.

Functions

This section is empty.

Types

type Creator

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

Creator maintains the state of a pseudo-random number generator used to create temp files.

func NewCreator

func NewCreator() *Creator

NewCreator returns a new Creator, for creating temp files.

func (*Creator) Create

func (c *Creator) Create(base string, legacy bool) (*os.File, string, error)

Create attempts to create a file whose name is of the form <base>-<randomstring> and with a ".v1" suffix if `legacy` is true. The file will be created with the setgid bit set, which indicates that it is not complete. The *os.File is returned along with the random string, and an error if something went wrong.

Once the file has been successfully written by the caller, it should be chmod'ed to `EndMode` to mark it as complete.

Jump to

Keyboard shortcuts

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