luci: go.chromium.org/luci/common/system/filesystem Index | Files

package filesystem

import "go.chromium.org/luci/common/system/filesystem"

Index

Package Files

filesystem.go tempdir.go

func AbsPath Uses

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 Uses

func IsNotExist(err error) bool

IsNotExist calls os.IsNotExist on the unwrapped err.

func MakeDirs Uses

func MakeDirs(path string) error

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

func MakePathUserWritable Uses

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 Uses

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 Uses

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 Touch Uses

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.

type TempDir Uses

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 Uses

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.

Package filesystem imports 8 packages (graph) and is imported by 19 packages. Updated 2018-12-19. Refresh now. Tools for package owners.