filter

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2023 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GitStyleDot gitStyle = iota
	GitStyleSym
	GitStyleDefault = GitStyleDot
)
View Source
const (
	OwnerName    = "owner"
	OwnerUidName = "owner-uid"
	OwnerSID     = "owner-sid"
)
View Source
const (
	GroupName    = "group"
	GroupUidName = "group-uid"
	GroupSID     = "group-sid"
)
View Source
const Inode = "Inode"
View Source
const MimeTypeName = "mine type"
View Source
const NameName = "name"
View Source
const Permissions = "Permissions"
View Source
const RelativeTime = "Relative-time"
View Source
const SizeName = "Size"
View Source
const SumName = "sum"

Variables

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

Functions

func Convert2SizeString added in v0.5.0

func Convert2SizeString(size SizeUnit) string

Types

type ContentFilter

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

func NewContentFilter

func NewContentFilter(options ...ContentOption) *ContentFilter

func (*ContentFilter) AppendToLengthFixed added in v0.5.1

func (cf *ContentFilter) AppendToLengthFixed(fixed ...LengthFixed)

func (*ContentFilter) AppendToOptions added in v0.5.0

func (cf *ContentFilter) AppendToOptions(options ...ContentOption)

func (*ContentFilter) EnableGroup added in v0.3.1

func (cf *ContentFilter) EnableGroup(renderer *render.Renderer) ContentOption

func (*ContentFilter) EnableOwner added in v0.3.1

func (cf *ContentFilter) EnableOwner(renderer *render.Renderer) ContentOption

func (*ContentFilter) EnableSum added in v0.5.0

func (cf *ContentFilter) EnableSum(sumTypes ...SumType) ContentOption

func (*ContentFilter) GetDisplayItems added in v0.6.0

func (cf *ContentFilter) GetDisplayItems(e ...os.FileInfo) []*display.Item

func (*ContentFilter) SetOptions added in v0.4.0

func (cf *ContentFilter) SetOptions(options ...ContentOption)

func (*ContentFilter) SetSortFunc added in v0.5.0

func (cf *ContentFilter) SetSortFunc(sortFunc func(a, b os.FileInfo) bool)

func (*ContentFilter) SortFunc added in v0.5.0

func (cf *ContentFilter) SortFunc() func(a, b os.FileInfo) bool

type ContentFunc

type ContentFunc func(entry os.FileInfo) bool

type ContentOption

type ContentOption func(info os.FileInfo) (stringContent string, funcName string)

func EnableFileMode

func EnableFileMode(renderer *render.Renderer) ContentOption

EnableFileMode return file mode like -rwxrwxrwx/drwxrwxrwx

func EnableTime

func EnableTime(format string, mode string, renderer *render.Renderer) ContentOption

type InodeEnabler added in v0.5.1

type InodeEnabler struct {
	*sync.WaitGroup
}

func NewInodeEnabler added in v0.5.1

func NewInodeEnabler() *InodeEnabler

func (*InodeEnabler) Enable added in v0.5.1

func (i *InodeEnabler) Enable(renderer *render.Renderer) ContentOption

type LengthFixed added in v0.5.1

type LengthFixed interface {
	Done()
	Wait()
	Add(delta int)
}

type LinkEnabler added in v0.7.0

type LinkEnabler struct {
	// List each file's number of hard links.
	*sync.WaitGroup
}

func NewLinkEnabler added in v0.7.0

func NewLinkEnabler() *LinkEnabler

func (*LinkEnabler) Enable added in v0.7.0

func (l *LinkEnabler) Enable() ContentOption

type MimeFileTypeEnabler added in v0.7.0

type MimeFileTypeEnabler struct {
	*sync.WaitGroup
	ParentOnly bool
}

func NewMimeFileTypeEnabler added in v0.7.0

func NewMimeFileTypeEnabler() *MimeFileTypeEnabler

func (*MimeFileTypeEnabler) Enable added in v0.7.0

func (e *MimeFileTypeEnabler) Enable() ContentOption

type Name added in v0.3.0

type Name struct {
	Icon, Classify, FileType bool
	Renderer                 *render.Renderer
	GitCache                 *cached.Map[git.GitRepoPath, *git.FileGits]

	GitStyle gitStyle
	Quote    string
	// contains filtered or unexported fields
}

func NewNameEnable added in v0.3.0

func NewNameEnable() *Name

func (*Name) Enable added in v0.3.0

func (n *Name) Enable() ContentOption

func (*Name) GitByName added in v0.4.0

func (n *Name) GitByName(name string, status string, style gitStyle) string

func (*Name) SetClassify added in v0.3.0

func (n *Name) SetClassify() *Name

func (*Name) SetFileType added in v0.3.0

func (n *Name) SetFileType() *Name

SetFileType set file type, should set Classify first if Classify is false, FileType will be ignored

func (*Name) SetGit added in v0.4.0

func (n *Name) SetGit() *Name

func (*Name) SetIcon added in v0.3.0

func (n *Name) SetIcon() *Name

func (*Name) SetParent added in v0.3.0

func (n *Name) SetParent(parent string) *Name

func (*Name) SetQuote added in v0.7.0

func (n *Name) SetQuote(quote string) *Name

func (*Name) SetRenderer added in v0.3.0

func (n *Name) SetRenderer(renderer *render.Renderer) *Name

func (*Name) SetStatistics added in v0.7.0

func (n *Name) SetStatistics(Statistics *Statistics)

func (*Name) Statistics added in v0.7.0

func (n *Name) Statistics() *Statistics

func (*Name) UnsetClassify added in v0.3.0

func (n *Name) UnsetClassify() *Name

func (*Name) UnsetFileType added in v0.3.0

func (n *Name) UnsetFileType() *Name

func (*Name) UnsetGit added in v0.4.0

func (n *Name) UnsetGit() *Name

func (*Name) UnsetIcon added in v0.3.0

func (n *Name) UnsetIcon() *Name

func (*Name) UnsetQuote added in v0.7.0

func (n *Name) UnsetQuote() *Name

type RelativeTimeEnabler added in v0.5.8

type RelativeTimeEnabler struct {
	*sync.WaitGroup
	Mode string
}

func NewRelativeTimeEnabler added in v0.5.8

func NewRelativeTimeEnabler() *RelativeTimeEnabler

func (*RelativeTimeEnabler) Enable added in v0.5.8

func (r *RelativeTimeEnabler) Enable(renderer *render.Renderer) ContentOption

type Size

type Size struct {
	Bytes uint64
}

func ParseSize added in v0.6.0

func ParseSize(size string) (Size, error)

type SizeEnabler added in v0.5.1

type SizeEnabler struct {
	*sync.WaitGroup
	// contains filtered or unexported fields
}

func NewSizeEnabler added in v0.5.1

func NewSizeEnabler() *SizeEnabler

func (*SizeEnabler) DisableTotal added in v0.5.1

func (s *SizeEnabler) DisableTotal()

func (*SizeEnabler) EnableSize added in v0.5.1

func (s *SizeEnabler) EnableSize(size SizeUnit) ContentOption

func (*SizeEnabler) Recursive added in v0.7.0

func (s *SizeEnabler) Recursive() *SizeRecursive

func (*SizeEnabler) Reset added in v0.5.1

func (s *SizeEnabler) Reset()

func (*SizeEnabler) SetEnableTotal added in v0.5.1

func (s *SizeEnabler) SetEnableTotal()

func (*SizeEnabler) SetRecursive added in v0.7.0

func (s *SizeEnabler) SetRecursive(sr *SizeRecursive)

func (*SizeEnabler) SetRenderer added in v0.5.1

func (s *SizeEnabler) SetRenderer(renderer *render.Renderer)

func (*SizeEnabler) Size2String added in v0.5.1

func (s *SizeEnabler) Size2String(b int64, blank int) string

func (*SizeEnabler) SizeUint added in v0.5.1

func (s *SizeEnabler) SizeUint() SizeUnit

func (*SizeEnabler) Total added in v0.5.1

func (s *SizeEnabler) Total() (size int64, ok bool)

type SizeRecursive added in v0.7.0

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

func NewSizeRecursive added in v0.7.0

func NewSizeRecursive(depth int) *SizeRecursive

type SizeUnit added in v0.3.1

type SizeUnit float64
const (
	Auto SizeUnit = iota
	Bit  SizeUnit = 1.0 << (10 * iota)
	B
	KB
	MB
	GB
	TB
	PB
	EB
	ZB
	YB
	BB
	NB
)
const Unknown SizeUnit = -1

func ConvertFromSizeString added in v0.5.0

func ConvertFromSizeString(size string) SizeUnit

type Statistics added in v0.7.0

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

func (*Statistics) Reset added in v0.7.0

func (s *Statistics) Reset()

func (*Statistics) String added in v0.7.0

func (s *Statistics) String() string

type SumType added in v0.5.0

type SumType int
const (
	SumTypeMd5 SumType = iota + 1
	SumTypeSha1
	SumTypeSha224
	SumTypeSha256
	SumTypeSha384
	SumTypeSha512
	SumTypeCRC32
)

type TypeFilter

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

func NewTypeFilter

func NewTypeFilter(tfs ...*TypeFunc) *TypeFilter

func (*TypeFilter) AppendTo added in v0.4.1

func (tf *TypeFilter) AppendTo(typeFunc ...*TypeFunc)

func (*TypeFilter) Filter

func (tf *TypeFilter) Filter(e ...os.FileInfo) (res []os.FileInfo)

type TypeFunc

type TypeFunc = func(e os.FileInfo) bool

TypeFunc return true -> Keep return false -> remove

func ExactFileTypeOnly added in v0.6.0

func ExactFileTypeOnly(fileTypes ...string) TypeFunc

func ExtOnly

func ExtOnly(ext ...string) TypeFunc

func GlobOnly added in v0.5.0

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

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

func RemoveByExt

func RemoveByExt(ext ...string) TypeFunc

RemoveByExt

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

func RemoveExactFileType added in v0.6.0

func RemoveExactFileType(fileTypes ...string) TypeFunc

func RemoveGitIgnore added in v0.4.1

func RemoveGitIgnore(repoPath git.GitRepoPath) TypeFunc

func RemoveGlob added in v0.5.0

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

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

Jump to

Keyboard shortcuts

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