pathlib

package module
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2020 License: Apache-2.0 Imports: 6 Imported by: 35

README

pathlib

Inspired by Python's pathlib, made better by Golang.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDoesNotImplement = errors.Errorf("doesn't implement required interface")
)

Functions

This section is empty.

Types

type Path

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

Path is an object that represents a path

func Glob

func Glob(fs afero.Fs, pattern string) ([]*Path, error)

func NewPath

func NewPath(path string) *Path

NewPath returns a new OS path

func NewPathAfero

func NewPathAfero(path string, fs afero.Fs) *Path

NewPathAfero returns a Path object with the given Afero object

func (*Path) Afero

func (p *Path) Afero() afero.Afero

func (*Path) Chmod

func (p *Path) Chmod(mode os.FileMode) error

func (*Path) Chtimes

func (p *Path) Chtimes(atime time.Time, mtime time.Time) error

func (*Path) Equals

func (p *Path) Equals(other *Path) (bool, error)

Equals returns whether or not the path pointed to by other has the same resolved filepath as self.

func (*Path) Exists

func (p *Path) Exists() (bool, error)

Exists returns whether the path exists

func (*Path) GetLatest

func (p *Path) GetLatest() (*Path, error)

GetLatest returns the file or directory that has the most recent mtime. Only works if this path is a directory and it exists. If the directory is empty, the returned Path object will be nil.

func (*Path) Glob

func (p *Path) Glob(pattern string) ([]*Path, error)

Glob returns all matches of pattern relative to this object's path.

func (*Path) IsAbsolute

func (p *Path) IsAbsolute() bool

IsAbsolute returns whether or not the path is an absolute path. This is determined by checking if the path starts with a slash.

func (*Path) IsDir

func (p *Path) IsDir() (bool, error)

IsDir returns whether the path is a directory

func (*Path) IsFile

func (p *Path) IsFile() (bool, error)
func (p *Path) IsSymlink() (bool, error)

func (*Path) Join

func (p *Path) Join(elems ...string) *Path

func (*Path) Mkdir

func (p *Path) Mkdir(perm os.FileMode) error

func (*Path) MkdirAll

func (p *Path) MkdirAll(perm os.FileMode) error

func (*Path) Name

func (p *Path) Name() string

Name returns the string representing the final path component

func (*Path) Parent

func (p *Path) Parent() *Path

Parent returns the Path object of the parent directory

func (*Path) Path

func (p *Path) Path() string

Path returns the string representation of the path

func (*Path) ReadDir

func (p *Path) ReadDir() ([]os.FileInfo, error)

func (*Path) ReadFile

func (p *Path) ReadFile() ([]byte, error)

func (*Path) RelativeTo

func (p *Path) RelativeTo(other *Path) (*Path, error)

func (*Path) Remove

func (p *Path) Remove() error

func (*Path) RemoveAll

func (p *Path) RemoveAll() error

func (*Path) Rename

func (p *Path) Rename(target string) (*Path, error)

Rename this path to the given target and return the corresponding Path object.

func (*Path) RenamePath

func (p *Path) RenamePath(target *Path) (*Path, error)

RenamePath is the same as Rename except target is a Path object

func (*Path) Resolve

func (p *Path) Resolve() (*Path, error)

Resolve resolves the path to a real path

func (*Path) Stat

func (p *Path) Stat() (os.FileInfo, error)
func (p *Path) Symlink(target *Path) error

Symlink symlinks to the target location

func (*Path) WriteFile

func (p *Path) WriteFile(data []byte, perm os.FileMode) error

Jump to

Keyboard shortcuts

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