path

package
v0.0.0-...-e225f37 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FollowSymlinks    = true
	ExpandTilde       = true
	ConvertAllToSlash = true
)

Functions

func CollectFile

func CollectFile(entries map[RelPath]fs.DirEntry) func(de DirEntry) error

func Exists

func Exists(dir Path, fnames ...string) bool

func IsAbs

func IsAbs(p Path) bool

func IsDir

func IsDir(dir Path, fnames ...string) (bool, error)

func IsDirEmpty

func IsDirEmpty(dir AbsDir) (bool, error)

func LogFileError

func LogFileError(de DirEntry, err error) error

func PruneEmptyDir

func PruneEmptyDir(dir AbsDir) error

func Remove

func Remove(f Path, pruneDirs bool) error

func Rename

func Rename(oldPath, newPath Path) error

func Segments

func Segments(fpath Path) []string

func ShouldInExclude

func ShouldInExclude(includeGlobs ...Glob) func(excludeGlobs ...Glob) ShouldSkipFunc

func Walk

func Walk(
	fsToWalk fs.FS,
	shouldSkip ShouldSkipFunc,
	process ProcessFunc,
	handleError HandleErrorFunc,
) error

Types

type AbsDir

type AbsDir struct {
	AbsPath
}

func (AbsDir) Abs

func (p AbsDir) Abs() AbsPath

func (AbsDir) Append

func (p AbsDir) Append(relPath RelPath) Path

func (AbsDir) AsDir

func (p AbsDir) AsDir() AbsDir

func (AbsDir) AsRel

func (p AbsDir) AsRel() RelPath

func (AbsDir) Base

func (p AbsDir) Base() string

func (AbsDir) BaseName

func (p AbsDir) BaseName() string

func (AbsDir) Clean

func (p AbsDir) Clean() Path

func (AbsDir) Create

func (p AbsDir) Create() (*os.File, error)

func (AbsDir) CreateForced

func (p AbsDir) CreateForced() (*os.File, error)

func (AbsDir) Dir

func (p AbsDir) Dir() AbsDir
func (p AbsDir) EvalSymlinks() (Path, error)

func (AbsDir) Exists

func (p AbsDir) Exists() bool

func (AbsDir) ExpandHome

func (p AbsDir) ExpandHome() Path

func (AbsDir) Ext

func (p AbsDir) Ext() string

func (AbsDir) FromSlash

func (p AbsDir) FromSlash() Path

func (AbsDir) InsBeforeExt

func (p AbsDir) InsBeforeExt(inFix string) Path

func (AbsDir) IoFsFS

func (ad AbsDir) IoFsFS() fs.FS

func (AbsDir) IsAbs

func (p AbsDir) IsAbs() bool

func (AbsDir) IsDir

func (p AbsDir) IsDir() bool

func (AbsDir) IsDirEmpty

func (ad AbsDir) IsDirEmpty() (bool, error)

func (AbsDir) IsEmpty

func (p AbsDir) IsEmpty() bool

func (AbsDir) Join

func (p AbsDir) Join(names ...string) Path

func (AbsDir) MkdirAll

func (ad AbsDir) MkdirAll(perm os.FileMode) error

func (AbsDir) NotEmpty

func (p AbsDir) NotEmpty() bool

func (AbsDir) Open

func (p AbsDir) Open() (*os.File, error)

func (AbsDir) ReadFile

func (p AbsDir) ReadFile() ([]byte, error)

func (AbsDir) RenameTo

func (p AbsDir) RenameTo(newPath Path) error

func (AbsDir) Segments

func (p AbsDir) Segments() []string

func (AbsDir) Stat

func (p AbsDir) Stat() (fs.FileInfo, error)

func (AbsDir) String

func (p AbsDir) String() string

func (AbsDir) ToSlash

func (p AbsDir) ToSlash() Path

func (AbsDir) Walk

func (ad AbsDir) Walk(
	shouldSkip ShouldSkipFunc,
	process ProcessFunc,
	handleError HandleErrorFunc,

) error

func (AbsDir) WoExt

func (p AbsDir) WoExt() string

func (AbsDir) WriteFile

func (p AbsDir) WriteFile(data []byte, perm fs.FileMode) error

type AbsPath

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

func Abs

func Abs(p Path, fpathElems ...string) AbsPath

func AbsList

func AbsList(paths ...string) (aps []AbsPath)

func Stat

func Stat(dir Path, fnames ...string) (fpath AbsPath, err error)

func (AbsPath) Abs

func (p AbsPath) Abs() AbsPath

func (AbsPath) Append

func (p AbsPath) Append(relPath RelPath) Path

func (AbsPath) AsDir

func (p AbsPath) AsDir() AbsDir

func (AbsPath) AsRel

func (p AbsPath) AsRel() RelPath

func (AbsPath) Base

func (p AbsPath) Base() string

func (AbsPath) BaseName

func (p AbsPath) BaseName() string

func (AbsPath) Clean

func (p AbsPath) Clean() Path

func (AbsPath) Create

func (p AbsPath) Create() (*os.File, error)

func (AbsPath) CreateForced

func (p AbsPath) CreateForced() (*os.File, error)

func (AbsPath) Dir

func (p AbsPath) Dir() AbsDir
func (p AbsPath) EvalSymlinks() (Path, error)

func (AbsPath) Exists

func (p AbsPath) Exists() bool

func (AbsPath) ExpandHome

func (p AbsPath) ExpandHome() Path

func (AbsPath) Ext

func (p AbsPath) Ext() string

func (AbsPath) FromSlash

func (p AbsPath) FromSlash() Path

func (AbsPath) InsBeforeExt

func (p AbsPath) InsBeforeExt(inFix string) Path

func (AbsPath) IsAbs

func (p AbsPath) IsAbs() bool

func (AbsPath) IsDir

func (p AbsPath) IsDir() bool

func (AbsPath) IsEmpty

func (p AbsPath) IsEmpty() bool

func (AbsPath) IsLocalTo

func (ap AbsPath) IsLocalTo(dir AbsDir) bool

func (AbsPath) Join

func (p AbsPath) Join(names ...string) Path

func (AbsPath) NotEmpty

func (p AbsPath) NotEmpty() bool

func (AbsPath) Open

func (p AbsPath) Open() (*os.File, error)

func (AbsPath) ReadFile

func (p AbsPath) ReadFile() ([]byte, error)

func (AbsPath) Rel

func (ap AbsPath) Rel(baseDir AbsDir) RelPath

func (AbsPath) Remove

func (ap AbsPath) Remove(pruneDirs bool) error

func (AbsPath) RenameTo

func (p AbsPath) RenameTo(newPath Path) error

func (AbsPath) Segments

func (p AbsPath) Segments() []string

func (AbsPath) Stat

func (p AbsPath) Stat() (fs.FileInfo, error)

func (AbsPath) String

func (p AbsPath) String() string

func (AbsPath) SymlinkTo

func (ap AbsPath) SymlinkTo(tgtPath AbsPath) error

func (AbsPath) ToSlash

func (p AbsPath) ToSlash() Path

func (AbsPath) WoExt

func (p AbsPath) WoExt() string

func (AbsPath) WriteFile

func (p AbsPath) WriteFile(data []byte, perm fs.FileMode) error

type DirEntry

type DirEntry interface {
	fs.DirEntry
	RelPath() RelPath
}

type Glob

type Glob struct {
	Pattern string
	// contains filtered or unexported fields
}

func NewGlob

func NewGlob(globPattern string) Glob

func NewGlobsFromStrings

func NewGlobsFromStrings(sL ...string) (globs []Glob)

func (Glob) Files

func (glob Glob) Files(baseDir AbsDir) ([]Path, error)

func (Glob) Matches

func (glob Glob) Matches(s string) bool

type Globs

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

func NewGlobs

func NewGlobs(globPatterns ...Glob) Globs

func (Globs) Files

func (globs Globs) Files(baseDir AbsDir) ([]Path, error)

func (Globs) Matches

func (globs Globs) Matches(s string) bool

type HandleErrorFunc

type HandleErrorFunc func(de DirEntry, err error) error

type List

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

func NewList

func NewList() List

func (*List) Add

func (l *List) Add(p AbsPath)

func (List) BaseDir

func (l List) BaseDir() AbsDir

func (List) Rel

func (l List) Rel(p AbsPath) RelPath

type Path

type Path interface {
	String() string
	IsEmpty() bool
	NotEmpty() bool
	Base() string
	Ext() string
	BaseName() string
	WoExt() string
	InsBeforeExt(inFix string) Path
	ToSlash() Path
	FromSlash() Path
	Clean() Path
	ExpandHome() Path
	EvalSymlinks() (Path, error)
	Abs() AbsPath
	Dir() AbsDir
	AsDir() AbsDir
	AsRel() RelPath
	Join(names ...string) Path
	Append(relPath RelPath) Path
	IsAbs() bool
	IsDir() bool

	Stat() (fs.FileInfo, error)
	Open() (*os.File, error)
	Create() (*os.File, error)
	CreateForced() (*os.File, error)
	Exists() bool
	RenameTo(newPath Path) error
	ReadFile() ([]byte, error)
	WriteFile(data []byte, perm fs.FileMode) error
}

func Append

func Append(p Path, relPath RelPath) Path

func Clean

func Clean(p Path) Path
func EvalSymlinks(p Path) (Path, error)

func ExpandHome

func ExpandHome(p Path) Path

func FromSlash

func FromSlash(p Path) Path

func InsBeforeExt

func InsBeforeExt(fpath Path, inFix string) Path

func Join

func Join(p Path, names ...string) Path

func New

func New(s string) Path

func ToSlash

func ToSlash(p Path) Path

type ProcessFunc

type ProcessFunc func(de DirEntry) error

type RelPath

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

func (RelPath) Abs

func (p RelPath) Abs() AbsPath

func (RelPath) Append

func (p RelPath) Append(relPath RelPath) Path

func (RelPath) AsDir

func (p RelPath) AsDir() AbsDir

func (RelPath) AsRel

func (p RelPath) AsRel() RelPath

func (RelPath) Base

func (p RelPath) Base() string

func (RelPath) BaseName

func (p RelPath) BaseName() string

func (RelPath) Clean

func (p RelPath) Clean() Path

func (RelPath) Create

func (p RelPath) Create() (*os.File, error)

func (RelPath) CreateForced

func (p RelPath) CreateForced() (*os.File, error)

func (RelPath) Dir

func (p RelPath) Dir() AbsDir
func (p RelPath) EvalSymlinks() (Path, error)

func (RelPath) Exists

func (p RelPath) Exists() bool

func (RelPath) ExpandHome

func (p RelPath) ExpandHome() Path

func (RelPath) Ext

func (p RelPath) Ext() string

func (RelPath) FromSlash

func (p RelPath) FromSlash() Path

func (RelPath) InsBeforeExt

func (p RelPath) InsBeforeExt(inFix string) Path

func (RelPath) IsAbs

func (p RelPath) IsAbs() bool

func (RelPath) IsDir

func (p RelPath) IsDir() bool

func (RelPath) IsEmpty

func (p RelPath) IsEmpty() bool

func (RelPath) Join

func (p RelPath) Join(names ...string) Path

func (RelPath) NotEmpty

func (p RelPath) NotEmpty() bool

func (RelPath) Open

func (p RelPath) Open() (*os.File, error)

func (RelPath) ReadFile

func (p RelPath) ReadFile() ([]byte, error)

func (RelPath) RenameTo

func (p RelPath) RenameTo(newPath Path) error

func (RelPath) Segments

func (p RelPath) Segments() []string

func (RelPath) Stat

func (p RelPath) Stat() (fs.FileInfo, error)

func (RelPath) String

func (p RelPath) String() string

func (RelPath) ToSlash

func (p RelPath) ToSlash() Path

func (RelPath) WoExt

func (p RelPath) WoExt() string

func (RelPath) WriteFile

func (p RelPath) WriteFile(data []byte, perm fs.FileMode) error

type ShouldSkipFunc

type ShouldSkipFunc func(de fs.DirEntry) (bool, error)

func ShouldSkip

func ShouldSkip(excludeRXs ...Glob) ShouldSkipFunc

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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