filesystem

package
v0.0.0-...-678bb0e Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsPath

func AbsPath(base *string) error

AbsPath is a convenience wrapper around filepath.Abs that accepts a string pointer, base, and updates it on successful resolution.

func IsNotExist

func IsNotExist(err error) bool

IsNotExist calls os.IsNotExist on the unwrapped err.

func MakeDirs

func MakeDirs(path string) error

MakeDirs is a convenience wrapper around os.MkdirAll that applies a 0755 mask to all created directories.

func MakeReadOnly

func MakeReadOnly(path string, filter func(string) bool) error

MakeReadOnly recursively iterates through all of the files and directories starting at path and marks them read-only.

func RemoveAll

func RemoveAll(path string) error

RemoveAll is a wrapper around os.RemoveAll which makes sure all files are writeable (recursively) prior to removing them.

func Touch

func Touch(path string, when time.Time, mode os.FileMode) error

Touch creates a new, empty file at the specified path.

If when is zero-value, time.Now will be used.

Types

type TempDir

type TempDir struct {
	// Dir is the base diectory. If empty, the default will be used (see
	// ioutil.TempDir)
	Dir string

	// Prefix is the prefix to apply to the temporary directory. If empty, a
	// default will be used (see ioutil.TempDir).
	Prefix string

	// OnCleanupErr, if not nil, will be called if TempDir cleanup fails.
	//
	// If nil, cleanup errors will be silently discarded.
	CleanupErrFunc func(tdir string, err error)
}

TempDir configures a temporary directory.

func (*TempDir) With

func (td *TempDir) With(fn func(string) error) error

With creates a temporary directory and passes it to fn. After fn exits, the directory and all of its contents is deleted.

Any error that happens during setup or execution of the callback is returned. If an error occurs during cleanup, the optional CleanupErrFunc will be called.

Jump to

Keyboard shortcuts

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