filter

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const MimeTypeName = constval.NameOfMIME

Variables

View Source
var DirOnly = func(e *item.FileInfo) bool {
	return e.IsDir()
}
View Source
var HiddenOnly = func(e *item.FileInfo) bool {
	return strings.HasPrefix(e.Name(), ".")
}
View Source
var RemoveBackups = func(e *item.FileInfo) bool {
	return !strings.HasSuffix(e.Name(), "~")
}
View Source
var RemoveDir = func(e *item.FileInfo) bool {
	return !e.IsDir()
}
View Source
var RemoveHidden = func(e *item.FileInfo) bool {
	return !strings.HasPrefix(e.Name(), ".")
}

Functions

func WhichTimeFiled

func WhichTimeFiled(mod string) (t func(os.FileInfo) time.Time)

Types

type ItemFilter

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

func NewItemFilter

func NewItemFilter(tfs ...*ItemFilterFunc) *ItemFilter

func (*ItemFilter) AppendTo

func (tf *ItemFilter) AppendTo(typeFunc ...*ItemFilterFunc)

func (*ItemFilter) Filter

func (tf *ItemFilter) Filter(e ...*item.FileInfo) (res []*item.FileInfo)

func (*ItemFilter) Match

func (tf *ItemFilter) Match(e *item.FileInfo) bool

type ItemFilterFunc

type ItemFilterFunc = func(e *item.FileInfo) bool

ItemFilterFunc return true -> Keep return false -> remove

func AfterTime

func AfterTime(t time.Time, timeFunc func(os.FileInfo) time.Time) ItemFilterFunc

func BeforeTime

func BeforeTime(t time.Time, timeFunc func(os.FileInfo) time.Time) ItemFilterFunc

func ExtOnly

func ExtOnly(ext ...string) ItemFilterFunc

func GlobOnly

func GlobOnly(globPattern ...string) (ItemFilterFunc, error)

GlobOnly if all pattern complied successfully, return a func and nil error, if match any one, the fn will return keep, else return remove if error occurred, return nil func and error

func MimeTypeOnly

func MimeTypeOnly(fileTypes ...string) ItemFilterFunc

func RemoveByExt

func RemoveByExt(ext ...string) ItemFilterFunc

RemoveByExt

eg:
	a.go b.c c.rs d.cxx dir
	RemoveByExt([]string{"go", "cxx"})
result:
	b.c c.rs dir

func RemoveGitIgnore

func RemoveGitIgnore(repoPath git.RepoPath) ItemFilterFunc

func RemoveGlob

func RemoveGlob(globPattern ...string) (ItemFilterFunc, error)

RemoveGlob if all pattern complied successfully, return a func and nil error, if match any one, the fn will return remove, else return keep if error occurred, return nil func and error

func RemoveMimeType

func RemoveMimeType(fileTypes ...string) ItemFilterFunc

Jump to

Keyboard shortcuts

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