func FindNotPredicate(predicate FindPredicate) FindPredicate {
	return func(f uefi.Firmware) bool {
		return !predicate(f)
	}
}
FindNotPredicate is a generic predicate which takes the logical NOT of an existing predicate.
package visitors
import (
	"encoding/json"
	"fmt"
	"io"
	"os"
	"regexp"
	"github.com/linuxboot/fiano/pkg/guid"
	"github.com/linuxboot/fiano/pkg/log"
	"github.com/linuxboot/fiano/pkg/uefi"
)
type FindPredicate = func(f uefi.Firmware) bool
type Find struct {
	Predicate FindPredicate
	Matches []uefi.Firmware
	W io.Writer
	currentFile *uefi.File
}
func (v *Find) Run(f uefi.Firmware) error {
	if err := f.Apply(v); err != nil {
		return err
	}
	if v.W != nil {
		b, err := json.MarshalIndent(v.Matches, "", "\t")
		if err != nil {
			log.Fatalf("%v", err)
		}
		fmt.Fprintln(v.W, string(b))
	}
	return nil
}
func (v *Find) Visit(f uefi.Firmware) error {
	switch f := f.(type) {
	case *uefi.File:
		v2 := &Find{
			Predicate:   v.Predicate,
			currentFile: f,
		}
		if v.Predicate(f) {
			v.Matches = append(v.Matches, f)
			v2.currentFile = nil
		}
		err := f.ApplyChildren(v2)
		v.Matches = append(v.Matches, v2.Matches...)  
		return err
	case *uefi.Section:
		if v.currentFile != nil && v.Predicate(f) {
			v.Matches = append(v.Matches, v.currentFile)
			v.currentFile = nil  
		}
		return f.ApplyChildren(v)
	case *uefi.NVar:
		if v.Predicate(f) {
			v.Matches = append(v.Matches, f)
		}
		return nil
	default:
		if v.Predicate(f) {
			v.Matches = append(v.Matches, f)
		}
		return f.ApplyChildren(v)
	}
}
func FindFileGUIDPredicate(r guid.GUID) FindPredicate {
	return func(f uefi.Firmware) bool {
		if f, ok := f.(*uefi.File); ok {
			return f.Header.GUID == r
		}
		return false
	}
}
func FindFileTypePredicate(t uefi.FVFileType) FindPredicate {
	return func(f uefi.Firmware) bool {
		if f, ok := f.(*uefi.File); ok {
			return f.Header.Type == t
		}
		return false
	}
}
func FindFilePredicate(r string) (func(f uefi.Firmware) bool, error) {
	ciRE, err := regexp.Compile("^(?i)(" + r + ")$")
	if err != nil {
		return nil, err
	}
	return func(f uefi.Firmware) bool {
		switch f := f.(type) {
		case *uefi.File:
			return ciRE.MatchString(f.Header.GUID.String())
		case *uefi.Section:
			return ciRE.MatchString(f.Name)
		}
		return false
	}, nil
}
func FindFileFVPredicate(r string) (func(f uefi.Firmware) bool, error) {
	ciRE, err := regexp.Compile("^(?i)" + r + "$")
	if err != nil {
		return nil, err
	}
	return func(f uefi.Firmware) bool {
		switch f := f.(type) {
		case *uefi.FirmwareVolume:
			return ciRE.MatchString(f.FVName.String())
		case *uefi.File:
			return ciRE.MatchString(f.Header.GUID.String())
		case *uefi.Section:
			return ciRE.MatchString(f.Name)
		}
		return false
	}, nil
}