fs

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNonAbsoluteProjectPath = errors.New("project path is not an absolute path")
	ErrInsecureProjectPath    = errors.New("project path is insecure")
	ErrInsecureTargetPath     = errors.New("target path is insecure")
	ErrOutsideBounds          = errors.New("final path is not inside project directory")
)

Functions

func ExcludesWalker

func ExcludesWalker(projectPath, targetPath string) (iter.Seq2[WalkerEntry, error], error)

ExcludesWalker returns an iterator that yields the entries from a filepath.WalkDir call, filtered by the ExcludesMatcher for 'targetPath'.

func GetRelativePath

func GetRelativePath(projectPath, targetPath string) (string, error)

GetRelativePath ensures that 'targetPath' does not attempt to escape 'projectPath', and returns the combined path if it can be done safely.

Types

type ExcludeMatcher

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

ExcludeMatcher wraps the gitignore Matcher from go-git and handles the path-splitting it requires automatically.

func GetExcludeMatcher

func GetExcludeMatcher(projectPath string) ExcludeMatcher

GetExcludeMatcher looks at a few locations to get exclusion files, then returns an ExcludeMatcher that will exclude files referenced within them. Those files are:

- [projectPath]/.smokeignore - $HOME/.smokeignore - $XDG_CONFIG_HOME/smoke/ignore - $HOME/config/smoke/ignore (if no $XDG_CONFIG_HOME defined)

func (ExcludeMatcher) Match

func (m ExcludeMatcher) Match(path string, isDir bool) bool

type WalkerEntry

type WalkerEntry struct {
	Path     string
	RelPath  string
	DirEntry fs.DirEntry
}

WalkerEntry has the details returned by a single iteration of an fs.WalkDirFunc call during filepath.WalkDir.

Jump to

Keyboard shortcuts

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