paths

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CopyEvent

type CopyEvent struct{ TargetEvent }

type CopyOverEvent

type CopyOverEvent struct{ TargetEvent }

type CreateFileEvent

type CreateFileEvent struct{ FileEvent }

type DeleteDirEvent

type DeleteDirEvent struct{ Event }

type DeleteFileEvent

type DeleteFileEvent struct{ FileEvent }

type Digest

type Digest []byte

func (Digest) Equals

func (d Digest) Equals(other Digest) bool

func (Digest) Hex

func (d Digest) Hex() string

type Error

type Error string
const (
	ErrDirectory    Error = "file is a directory"
	ErrNonDirectory Error = "not a directory"
	ErrNonLink      Error = "not a link"
	ErrPathNotFound Error = "path not found"
	ErrFileExists   Error = "path already exists"
	ErrBrokenLink   Error = "broken link"
	ErrNotWritable  Error = "not writable"
	ErrInvalid      Error = "invalid"
)

func (Error) Error

func (e Error) Error() string

type Event

type Event interface{ Path() *Path }

type File

type File interface {
	io.ReadCloser
	io.WriteSeeker
}

type FileEvent

type FileEvent interface {
	Event
	Size() int64
}

type Listener

type Listener func(event Event)

type Path

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

func (*Path) Append

func (p *Path) Append() (File, error)

func (*Path) AppendMode

func (p *Path) AppendMode(mode os.FileMode) (file File, err error)

func (*Path) Base

func (p *Path) Base() string

func (*Path) BytesAreEqual

func (p *Path) BytesAreEqual(other *Path) (isEqual bool, err error)

func (*Path) BytesAreEqualToBytes

func (p *Path) BytesAreEqualToBytes(other []byte) (isEqual bool, err error)

func (*Path) BytesIfExistsAreEqual

func (p *Path) BytesIfExistsAreEqual(other *Path) (isEqual bool, err error)

func (*Path) BytesIfExistsAreEqualToBytes

func (p *Path) BytesIfExistsAreEqualToBytes(other []byte) (isEqual bool, err error)

func (*Path) Children

func (p *Path) Children() (paths Paths, err error)

func (*Path) ChildrenIfIsDir

func (p *Path) ChildrenIfIsDir() (Paths, error)

func (*Path) Chmod

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

func (*Path) CopyTo

func (p *Path) CopyTo(target *Path) error

func (*Path) Create

func (p *Path) Create() (File, error)

func (*Path) CreateMode

func (p *Path) CreateMode(mode os.FileMode) (file File, err error)

func (*Path) Delete

func (p *Path) Delete() (err error)

func (*Path) DeleteIfExists

func (p *Path) DeleteIfExists() error

func (*Path) Digest

func (p *Path) Digest(hash hash.Hash) (d Digest, err error)

func (*Path) DigestIfExists

func (p *Path) DigestIfExists(hash hash.Hash) (d Digest, err error)

func (*Path) Exists

func (p *Path) Exists() bool

func (*Path) Extension

func (p *Path) Extension() string

func (*Path) Glob

func (p *Path) Glob(pattern string) (paths Paths, err error)

func (*Path) IsDir

func (p *Path) IsDir() bool

func (*Path) IsEmpty

func (p *Path) IsEmpty() (isEmpty bool, err error)

func (*Path) IsNonDir

func (p *Path) IsNonDir() bool

func (*Path) Join

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

func (*Path) KeepChildren

func (p *Path) KeepChildren(childNames ...string) (err error)

func (*Path) Make

func (p *Path) Make() error

func (*Path) MakeMode

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

func (*Path) MustAppend

func (p *Path) MustAppend() File

func (*Path) MustAppendMode

func (p *Path) MustAppendMode(mode os.FileMode) File

func (*Path) MustBytesAreEqual

func (p *Path) MustBytesAreEqual(other *Path) bool

func (*Path) MustBytesAreEqualToBytes

func (p *Path) MustBytesAreEqualToBytes(other []byte) bool

func (*Path) MustBytesIfExistsAreEqual

func (p *Path) MustBytesIfExistsAreEqual(other *Path) bool

func (*Path) MustBytesIfExistsAreEqualToBytes

func (p *Path) MustBytesIfExistsAreEqualToBytes(other []byte) bool

func (*Path) MustChildren

func (p *Path) MustChildren() Paths

func (*Path) MustChildrenIfIsDir

func (p *Path) MustChildrenIfIsDir() Paths

func (*Path) MustChmod

func (p *Path) MustChmod(mode os.FileMode)

func (*Path) MustCreate

func (p *Path) MustCreate() File

func (*Path) MustCreateMode

func (p *Path) MustCreateMode(mode os.FileMode) File

func (*Path) MustDelete

func (p *Path) MustDelete()

func (*Path) MustDeleteIfExists

func (p *Path) MustDeleteIfExists()

func (*Path) MustDigest

func (p *Path) MustDigest(hash hash.Hash) Digest

func (*Path) MustDigestIfExists

func (p *Path) MustDigestIfExists(hash hash.Hash) Digest

func (*Path) MustGlob

func (p *Path) MustGlob(pattern string) Paths

func (*Path) MustIsEmpty

func (p *Path) MustIsEmpty() bool

func (*Path) MustKeepChildren

func (p *Path) MustKeepChildren(childNames ...string)

func (*Path) MustMake

func (p *Path) MustMake() *Path

func (*Path) MustMakeMode

func (p *Path) MustMakeMode(mode os.FileMode) *Path

func (*Path) MustOpen

func (p *Path) MustOpen() File

func (*Path) MustReadBytes

func (p *Path) MustReadBytes() []byte

func (*Path) MustReadBytesIfExists

func (p *Path) MustReadBytesIfExists() []byte
func (p *Path) MustReadLink() *Path

func (*Path) MustReadString

func (p *Path) MustReadString() string

func (*Path) MustReadStringIfExists

func (p *Path) MustReadStringIfExists() string

func (*Path) MustReadTo

func (p *Path) MustReadTo(writer io.Writer)

func (*Path) MustReadToIfExists

func (p *Path) MustReadToIfExists(writer io.Writer)

func (*Path) MustRemoveEmptyDirs

func (p *Path) MustRemoveEmptyDirs() (removed Paths)

func (*Path) MustRemoveEmptyDirsAndSelf

func (p *Path) MustRemoveEmptyDirsAndSelf() (removed Paths)

func (*Path) MustRemoveEmptyDirsRecursive

func (p *Path) MustRemoveEmptyDirsRecursive() (removed Paths)

func (*Path) MustRemoveEmptyDirsRecursiveAndSelf

func (p *Path) MustRemoveEmptyDirsRecursiveAndSelf() (removed Paths)

func (*Path) MustRename

func (p *Path) MustRename(target *Path)

func (*Path) MustSha1Digest

func (p *Path) MustSha1Digest() Digest

func (*Path) MustSha1DigestIfExists

func (p *Path) MustSha1DigestIfExists() Digest

func (*Path) MustSha224Digest

func (p *Path) MustSha224Digest() Digest

func (*Path) MustSha224DigestIfExists

func (p *Path) MustSha224DigestIfExists() Digest

func (*Path) MustSha256Digest

func (p *Path) MustSha256Digest() Digest

func (*Path) MustSha256DigestIfExists

func (p *Path) MustSha256DigestIfExists() Digest

func (*Path) MustSha384Digest

func (p *Path) MustSha384Digest() Digest

func (*Path) MustSha384DigestIfExists

func (p *Path) MustSha384DigestIfExists() Digest

func (*Path) MustSha512Digest

func (p *Path) MustSha512Digest() Digest

func (*Path) MustSha512DigestIfExists

func (p *Path) MustSha512DigestIfExists() Digest

func (*Path) MustSize

func (p *Path) MustSize() int64

func (*Path) MustSizeIfExists

func (p *Path) MustSizeIfExists() int64

func (*Path) MustStat

func (p *Path) MustStat() os.FileInfo

func (*Path) MustSymlinkTo

func (p *Path) MustSymlinkTo(target *Path)

func (*Path) MustTouch

func (p *Path) MustTouch() *Path

func (*Path) MustWd

func (p *Path) MustWd() *Path

func (*Path) MustWriteBytes

func (p *Path) MustWriteBytes(b []byte)

func (*Path) MustWriteBytesUnlessEqual

func (p *Path) MustWriteBytesUnlessEqual(b []byte)

func (*Path) MustWriteFrom

func (p *Path) MustWriteFrom(reader io.Reader)

func (*Path) MustWriteString

func (p *Path) MustWriteString(s string)

func (*Path) MustWriteStringUnlessEqual

func (p *Path) MustWriteStringUnlessEqual(s string)

func (*Path) Open

func (p *Path) Open() (File, error)

func (*Path) Parent

func (p *Path) Parent() *Path

func (*Path) ReadBytes

func (p *Path) ReadBytes() (b []byte, err error)

func (*Path) ReadBytesIfExists

func (p *Path) ReadBytesIfExists() (b []byte, err error)
func (p *Path) ReadLink() (*Path, error)

func (*Path) ReadString

func (p *Path) ReadString() (string, error)

func (*Path) ReadStringIfExists

func (p *Path) ReadStringIfExists() (str string, err error)

func (*Path) ReadTo

func (p *Path) ReadTo(writer io.Writer) (err error)

func (*Path) ReadToIfExists

func (p *Path) ReadToIfExists(writer io.Writer) error

func (*Path) RemoveEmptyDirs

func (p *Path) RemoveEmptyDirs() (removed Paths, err error)

func (*Path) RemoveEmptyDirsAndSelf

func (p *Path) RemoveEmptyDirsAndSelf() (removed Paths, err error)

func (*Path) RemoveEmptyDirsRecursive

func (p *Path) RemoveEmptyDirsRecursive() (removed Paths, err error)

func (*Path) RemoveEmptyDirsRecursiveAndSelf

func (p *Path) RemoveEmptyDirsRecursiveAndSelf() (removed Paths, err error)

func (*Path) Rename

func (p *Path) Rename(target *Path) (err error)

func (*Path) Sha1Digest

func (p *Path) Sha1Digest() (Digest, error)

func (*Path) Sha1DigestIfExists

func (p *Path) Sha1DigestIfExists() (Digest, error)

func (*Path) Sha224Digest

func (p *Path) Sha224Digest() (Digest, error)

func (*Path) Sha224DigestIfExists

func (p *Path) Sha224DigestIfExists() (Digest, error)

func (*Path) Sha256Digest

func (p *Path) Sha256Digest() (Digest, error)

func (*Path) Sha256DigestIfExists

func (p *Path) Sha256DigestIfExists() (Digest, error)

func (*Path) Sha384Digest

func (p *Path) Sha384Digest() (Digest, error)

func (*Path) Sha384DigestIfExists

func (p *Path) Sha384DigestIfExists() (Digest, error)

func (*Path) Sha512Digest

func (p *Path) Sha512Digest() (Digest, error)

func (*Path) Sha512DigestIfExists

func (p *Path) Sha512DigestIfExists() (Digest, error)

func (*Path) Size

func (p *Path) Size() (int64, error)

func (*Path) SizeIfExists

func (p *Path) SizeIfExists() (int64, error)

func (*Path) Stat

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

func (*Path) String

func (p *Path) String() string

func (*Path) SymlinkTo

func (p *Path) SymlinkTo(target *Path) error

func (*Path) Touch

func (p *Path) Touch() error

func (*Path) UserHome

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

func (*Path) Wd

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

func (*Path) WriteBytes

func (p *Path) WriteBytes(b []byte) error

func (*Path) WriteBytesUnlessEqual

func (p *Path) WriteBytesUnlessEqual(b []byte) error

func (*Path) WriteCloser

func (p *Path) WriteCloser() io.WriteCloser

func (*Path) WriteFrom

func (p *Path) WriteFrom(reader io.Reader) (err error)

func (*Path) WriteString

func (p *Path) WriteString(s string) error

func (*Path) WriteStringUnlessEqual

func (p *Path) WriteStringUnlessEqual(s string) error

type Paths

type Paths []*Path

func (Paths) All

func (p Paths) All(predicate func(path *Path) bool) bool

func (Paths) Any

func (p Paths) Any(predicate func(path *Path) bool) bool

func (Paths) Dirs

func (p Paths) Dirs() (dirs Paths)

func (Paths) NonDirs

func (p Paths) NonDirs() (nonDirs Paths)

type RenameEvent

type RenameEvent struct{ TargetEvent }

type RewriteFileEvent

type RewriteFileEvent struct{ FileEvent }

type SymlinkEvent

type SymlinkEvent struct{ TargetEvent }

type System

type System interface {
	Chmod(name string, mode os.FileMode) error
	Chtimes(name string, atime time.Time, mtime time.Time) error
	CurrentUser() (*user.User, error)
	Getwd() (dir string, err error)
	Glob(pattern string) (matches []string, err error)
	Join(elem ...string) string
	Lstat(name string) (os.FileInfo, error)
	MkdirAll(path string, perm os.FileMode) error
	OpenFile(name string, flag int, perm os.FileMode) (File, error)
	ReadDir(name string) ([]os.DirEntry, error)
	ReadFile(name string) ([]byte, error)
	Readlink(name string) (string, error)
	Remove(name string) error
	RemoveAll(path string) error
	Rename(oldpath, newpath string) error
	Root() string
	SupportsSymlinks() bool
	Symlink(oldname, newname string) error
}
var LocalSystem System = local{}

type TargetEvent

type TargetEvent interface {
	Event
	Target() *Path
}

type Tree

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

func NewTree

func NewTree() (t *Tree)

func NewTreeWithSystem

func NewTreeWithSystem(system System) (t *Tree)

func (*Tree) Subscribe

func (t *Tree) Subscribe(listener Listener) (unsubscribe func())

type VirtualSystem

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

func NewVirtualSystem

func NewVirtualSystem() *VirtualSystem

func (*VirtualSystem) Chmod

func (v *VirtualSystem) Chmod(name string, mode os.FileMode) error

func (*VirtualSystem) Chtimes

func (v *VirtualSystem) Chtimes(name string, atime time.Time, mtime time.Time) error

func (*VirtualSystem) CurrentUser

func (v *VirtualSystem) CurrentUser() (*user.User, error)

func (*VirtualSystem) Getwd

func (v *VirtualSystem) Getwd() (dir string, err error)

func (*VirtualSystem) Glob

func (v *VirtualSystem) Glob(pattern string) (matches []string, err error)

func (*VirtualSystem) Join

func (v *VirtualSystem) Join(elem ...string) string

func (*VirtualSystem) Lstat

func (v *VirtualSystem) Lstat(name string) (os.FileInfo, error)

func (*VirtualSystem) MkdirAll

func (v *VirtualSystem) MkdirAll(path string, perm os.FileMode) error

func (*VirtualSystem) OpenFile

func (v *VirtualSystem) OpenFile(name string, flag int, perm os.FileMode) (File, error)

func (*VirtualSystem) ReadDir

func (v *VirtualSystem) ReadDir(name string) (entries []os.DirEntry, err error)

func (*VirtualSystem) ReadFile

func (v *VirtualSystem) ReadFile(name string) (b []byte, err error)
func (v *VirtualSystem) Readlink(name string) (string, error)

func (*VirtualSystem) Remove

func (v *VirtualSystem) Remove(name string) error

func (*VirtualSystem) RemoveAll

func (v *VirtualSystem) RemoveAll(path string) error

func (*VirtualSystem) Rename

func (v *VirtualSystem) Rename(oldpath, newpath string) error

func (*VirtualSystem) Root

func (v *VirtualSystem) Root() string
func (v *VirtualSystem) SupportsSymlinks() bool
func (v *VirtualSystem) Symlink(oldname, newname string) error

Jump to

Keyboard shortcuts

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