filter

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package filter implements the result filters used by fd: size, modification time and (on unix) ownership constraints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OwnerFilter

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

OwnerFilter constrains results by owning user and/or group.

func ParseOwner

func ParseOwner(input string) (OwnerFilter, bool, error)

ParseOwner parses an owner constraint of the form [(user|uid)][:(group|gid)]. Either side may be prefixed with '!' to negate. Returns ok=false when the constraint is a no-op (e.g. "" or ":").

func (OwnerFilter) Matches

func (f OwnerFilter) Matches(info os.FileInfo) bool

Matches reports whether the file described by info satisfies the constraint.

type SizeFilter

type SizeFilter struct {
	Kind  SizeKind
	Limit uint64
}

SizeFilter constrains results based on file size.

func ParseSize

func ParseSize(s string) (SizeFilter, error)

ParseSize parses a size constraint string like "+1m", "-500k", "10ki".

func (SizeFilter) IsWithin

func (f SizeFilter) IsWithin(size uint64) bool

IsWithin reports whether the given size satisfies the filter.

type SizeKind

type SizeKind int

SizeKind distinguishes the comparison used by a SizeFilter.

const (
	// SizeMin requires file size >= Limit.
	SizeMin SizeKind = iota
	// SizeMax requires file size <= Limit.
	SizeMax
	// SizeEquals requires file size == Limit.
	SizeEquals
)

type TimeFilter

type TimeFilter struct {
	Kind  TimeKind
	Limit time.Time
}

TimeFilter constrains results based on modification time.

func After

func After(s string) (TimeFilter, error)

After returns a filter matching files modified after the given time spec.

func Before

func Before(s string) (TimeFilter, error)

Before returns a filter matching files modified before the given time spec.

func (TimeFilter) AppliesTo

func (f TimeFilter) AppliesTo(t time.Time) bool

AppliesTo reports whether the modification time satisfies the filter.

type TimeKind

type TimeKind int

TimeKind distinguishes before/after comparisons.

const (
	// TimeBefore matches files modified before the limit.
	TimeBefore TimeKind = iota
	// TimeAfter matches files modified after the limit.
	TimeAfter
)

Jump to

Keyboard shortcuts

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