filesystem

package
v0.0.0-...-a0a3655 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2019 License: Apache-2.0 Imports: 11 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 MakePathUserWritable

func MakePathUserWritable(path string, fi os.FileInfo) error

MakePathUserWritable updates the filesystem metadata on a single file or directory to make it user-writable.

fi is optional. If nil, os.Stat will be called on path. Otherwise, fi will be regarded as the results of calling os.Stat on path. This is provided as an optimization, since some filesystem operations automatically yield a FileInfo.

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 MakeTreeFilesReadOnly

func MakeTreeFilesReadOnly(ctx context.Context, root string) error

MakeTreeFilesReadOnly makes all the files in the directories read only but not the directories themselves. This means files can be created or deleted.

func MakeTreeReadOnly

func MakeTreeReadOnly(ctx context.Context, root string) error

MakeTreeReadOnly makes all the files in the directories read only. Also makes the directories read only, only if it makes sense on the platform. This means no file can be created or deleted.

func MakeTreeWritable

func MakeTreeWritable(ctx context.Context, root string) error

MakeTreeWritable makes all the files in the directories writeable. Also makes the directories writeable, only if it makes sense on the platform.

func RemoveAll

func RemoveAll(path string) error

RemoveAll is a fork of os.RemoveAll that attempts to deal with read only files and directories by modifying permissions as necessary.

If the specified path does not exist, RemoveAll will return nil.

Note that RemoveAll will not modify permissions on parent directory of the provided path, even if it is read only and preventing deletion of the path on POSIX system.

Copied from https://go.googlesource.com/go/+/b86e76681366447798c94abb959bb60875bcc856/src/os/path.go#63

func SetReadOnly

func SetReadOnly(path string, readOnly bool) error

SetReadOnly sets or resets the write bit on a file or directory. Zaps out access to 'group' and 'others'.

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