ffinder

package module
v0.0.0-...-a12b00b Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: MIT Imports: 14 Imported by: 0

README

file-finder

File Finder Tool

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDirConfigFile

func GetDirConfigFile(ctx context.Context) (name string)

func WithDirConfigFile

func WithDirConfigFile(name string, ctx context.Context) context.Context

Types

type ContextKey

type ContextKey uint8
const (
	LoadDirConfigFile ContextKey = iota
)

type DirInput

type DirInput struct {
	Dir        string
	TrimPrefix string `mapstructure:"strip_prefix" yaml:"strip_prefix"`
	Prefix     string
	Recursive  bool
	Includes   FileMatchers
	Excludes   FileMatchers
	Sources    []DirInput
}

func (DirInput) Exclude

func (this DirInput) Exclude(pth string, info os.FileInfo) bool

func (DirInput) Find

func (this DirInput) Find(cb func(file File) error) (err error)

func (DirInput) Finder

func (this DirInput) Finder() (finder Finder)

func (DirInput) GetPrefix

func (this DirInput) GetPrefix() string

func (DirInput) GetTrimPrefix

func (this DirInput) GetTrimPrefix() string

func (DirInput) Include

func (this DirInput) Include(pth string, info os.FileInfo) bool

func (DirInput) IsRecursive

func (this DirInput) IsRecursive() bool

func (DirInput) PathOf

func (this DirInput) PathOf(realPath string) (pth string)

func (DirInput) Setup

func (this DirInput) Setup(ctx context.Context) (err error)

func (*DirInput) SetupTree

func (this *DirInput) SetupTree(ctx context.Context, prefix string) (err error)

type File

type File interface {
	fmt.Stringer
	os.FileInfo
	GetPath() string
	Reader() (r io.ReadCloser, err error)
}

type FileMatcher

type FileMatcher interface {
	Match(pth string, info os.FileInfo) bool
}

func FileMatchGlob

func FileMatchGlob(pattern string) (acceptor FileMatcher, err error)

func FileMatchRegex

func FileMatchRegex(pattern string) (acceptor FileMatcher, err error)

func ParseFileMatcher

func ParseFileMatcher(s string) (fm FileMatcher, err error)

type FileMatcherFunc

type FileMatcherFunc func(pth string, info os.FileInfo) bool

func (FileMatcherFunc) Match

func (this FileMatcherFunc) Match(pth string, info os.FileInfo) bool

type FileMatchers

type FileMatchers []FileMatcher

func ParseFileMatchers

func ParseFileMatchers(items ...string) (include, exclude FileMatchers, err error)

func (FileMatchers) Match

func (this FileMatchers) Match(pth string, info os.FileInfo) bool

func (*FileMatchers) Parse

func (this *FileMatchers) Parse(items ...string) (err error)

type Finder

type Finder interface {
	Find(cb func(file File) error) (err error)
}

type Finders

type Finders []Finder

func (Finders) Find

func (this Finders) Find(cb func(file File) error) (err error)

type Input

type Input interface {
	InputFinder
	GetTrimPrefix() string
	GetPrefix() string
	IsRecursive() bool
	Include(pth string, info os.FileInfo) bool
	Exclude(pth string, info os.FileInfo) bool
}

type InputFinder

type InputFinder interface {
	Setup(ctx context.Context) (err error)
	Finder() Finder
}

type InputFinders

type InputFinders []InputFinder

func (InputFinders) Finder

func (this InputFinders) Finder() Finder

func (InputFinders) Setup

func (this InputFinders) Setup(ctx context.Context) (err error)

type RealFile

type RealFile struct {
	os.FileInfo
	Path       string
	RealPath   string
	ReaderFunc func() (r io.ReadCloser, err error)
}

func NewRealFile

func NewRealFile(path, realPath string, info os.FileInfo) *RealFile

func (RealFile) GetPath

func (this RealFile) GetPath() string

func (RealFile) Reader

func (this RealFile) Reader() (r io.ReadCloser, err error)

func (*RealFile) String

func (this *RealFile) String() (s string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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