pathlib

package
v0.0.0-...-2f3f802 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotDir

func IsNotDir(err error) bool

func PosixSliceStringer

func PosixSliceStringer(ps []PosixPath) (str []string)

Types

type Dangerously

type Dangerously interface {
	Must() MustActions
}

type FileInfoAdditions

type FileInfoAdditions interface {
	IsBlockDevice() bool
	IsCharDevice() bool
	IsFifo() bool
	IsFile() bool
	IsSocket() bool
	IsSymlink() bool
}

type FlavorCasts

type FlavorCasts interface {
	Posixly
	Purely
	Dangerously
}

type Fs

type Fs interface {
	afero.Fs
	afero.Lstater
	Symlinker
	Globber
}

func GetFs

func GetFs() Fs

func SetFs

func SetFs(newFs Fs) (oldFs Fs)

type Globber

type Globber interface {
	Glob(pattern string) ([]string, error)
}

type LexOrderPosix

type LexOrderPosix []PosixPath

func (LexOrderPosix) Len

func (o LexOrderPosix) Len() int

func (LexOrderPosix) Less

func (o LexOrderPosix) Less(i, j int) bool

func (LexOrderPosix) Swap

func (o LexOrderPosix) Swap(i, j int)

type LexOrderPure

type LexOrderPure []PurePath

func (LexOrderPure) Len

func (o LexOrderPure) Len() int

func (LexOrderPure) Less

func (o LexOrderPure) Less(i, j int) bool

func (LexOrderPure) Swap

func (o LexOrderPure) Swap(i, j int)

type MustActions

type MustActions interface {
	FlavorCasts
	fmt.Stringer

	Mkdir(perm os.FileMode)
	MkdirAll(perm os.FileMode)
	Remove()
	RemoveAll()
	Touch(perm os.FileMode, existOk bool)

	// Match returns true if the pattern matches the last path component
	// of this path. Note that ths wlll only blow up if the pattern itself
	// is invalid
	Match(pattern string) bool

	// ExMatch performs an extended match on the entire path string using
	// the globbing library github.com/gobwas/glob. This function will only
	// blow up if the pattern is not valid
	ExMatch(pattern string) bool
}

these provide panic-inducing versions of the PosixPath actions for when you're pretty sure it's just gonna work and want the convenience

func NewMustAction

func NewMustAction(s string) MustActions

type PosixPath

type PosixPath interface {
	FileInfoAdditions
	FlavorCasts
	fmt.Stringer

	Name() string
	Parent() PosixPath
	Join(names ...string) PosixPath
	Clean() PosixPath
	Match(pattern string) (matched bool, err error)
	ExMatch(pattern string) (matched bool, err error)
	Split() (dir PosixPath, file string)
	Stat() (RichFileInfo, error)
	Lstat() (RichFileInfo, error)
	SymlinkTo(path string) error
	Rel(other string) (PosixPath, error)
	Resolve() (PosixPath, error)
	Mkdir(perm os.FileMode) error
	MkdirAll(perm os.FileMode) error
	Remove() error
	RemoveAll() error
	Lexists() bool
	Exists() bool
	IsMount() bool
	SameFile(other PosixPath) (bool, error)
	IsDir() bool
	Glob(pattern string) ([]PosixPath, error)
	Touch(perm os.FileMode, existOk bool) error
}

Provide path manipulation like PurePath, but also posix actions on the real filesystem. Note that the FileInfoAdditions actions on a PosixPath will ignore all errors and return false. This is the strategy that the Python stdlib 'pathlib' follows in the interest of ease of use. If you really need to know about every error type, then use Stat() and inspect the error case before interrogating the FileInfoAdditions method.

func NewPosixPath

func NewPosixPath(s string) PosixPath

type PosixPathOps

type PosixPathOps interface {
	Filter(fn func(pp PosixPath) bool) []PosixPath
	Find(fn func(pp PosixPath) bool) *PosixPath
}

type PosixPathOpsT

type PosixPathOpsT []PosixPath

func (PosixPathOpsT) Filter

func (p PosixPathOpsT) Filter(fn func(pp PosixPath) bool) []PosixPath

func (PosixPathOpsT) Find

func (p PosixPathOpsT) Find(fn func(pp PosixPath) bool) (found *PosixPath)

type Posixly

type Posixly interface {
	Posix() PosixPath
}

type PurePath

type PurePath interface {
	fmt.Stringer
	FlavorCasts

	Name() string
	Parent() PurePath
	Join(names ...string) PurePath
	Clean() PurePath
	Match(pattern string) (matched bool, err error)

	// ExMatch performs an extended match on this PurePath
	// see github.com/gobwas/glob for syntax.
	// (basically '**' is supported)
	ExMatch(pattern string) (matched bool, err error)
	Split() (dir PurePath, file string)
}

func NewPurePath

func NewPurePath(s string) PurePath

type Purely

type Purely interface {
	Pure() PurePath
}

type RichFileInfo

type RichFileInfo interface {
	os.FileInfo
	FileInfoAdditions
	String() string
	// contains filtered or unexported methods
}

type Symlinker

type Symlinker interface {
	Symlink(old, new string) error
}

Jump to

Keyboard shortcuts

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