lfs

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseFilter

func BaseFilter(el *Element) bool

func IsZipLike

func IsZipLike(path string) bool

Types

type Element

type Element struct {
	Name     string
	Path     string // includes name, relative path to cwd
	Mod      int64  // Unix time for mod
	Creation int64  // Unix time for creation
	Size     int64  // Size in bytes
	Mask     uint32 // Bitmask of element types, file, dir, content types, hidden, etc.
}

type FSSource

type FSSource struct {
	Paths  []string
	Els    []*Element
	Parser Parser
}

FSSource is a BFS source for traversing filesystem

func NewFSSource

func NewFSSource() *FSSource

func (*FSSource) Iter

func (s *FSSource) Iter() (res []*Element, curr string, ok bool)

func (*FSSource) Seed

func (s *FSSource) Seed(seeds []string)

func (*FSSource) SeedFromElements

func (s *FSSource) SeedFromElements(els []*Element)

type FSTraverser

type FSTraverser struct {
	MaxDepth int
	MinDepth int

	// Selection filter, determines which paths are and aren't traversed
	SelFilter func(*Element) bool
	// Result filter, determines which elments are and aren't included in result
	ResFilter func(*Element) bool

	FSW *FSWorker
	Src *FSSource

	common.Logger
}

func GetDefault

func GetDefault() *FSTraverser

func NewFSTraverser

func NewFSTraverser() *FSTraverser

func (*FSTraverser) Init

func (t *FSTraverser) Init()

func (*FSTraverser) Traverse

func (tr *FSTraverser) Traverse(src SourceIter[*Element, string]) (res []*Element)

type FSWorker

type FSWorker struct {
	Sort     SortBy
	Hide     bool
	Archives bool
	// Format directory paths to end with "/". Used for internal logic, turning it
	// off will remove file|directory selection functionality
	WebStyle bool
	common.Logger
}

func NewFSWorker

func NewFSWorker() *FSWorker

func (*FSWorker) Dir

func (fsw *FSWorker) Dir(path string) (files []fs.FileInfo, err error)

func (*FSWorker) Parse

func (fsw *FSWorker) Parse(path string) *Element

func (*FSWorker) Parser

func (fsw *FSWorker) Parser() func(string) ([]*Element, error)

func (*FSWorker) Zip

func (fsw *FSWorker) Zip(path string) (files []fs.FileInfo, err error)

type Parser

type Parser func(string) (res []*Element, err error)

type SortBy

type SortBy uint8
const (
	ByNone SortBy = iota
	ByName
	ByMod
	BySize
	ByCreation // Available only on Windows
)

type SourceIter

type SourceIter[T, S any] interface {
	Iter() (res []T, curr S, ok bool)
	Seed(seeds []S)
}

type Traverser

type Traverser[T, S any] interface {
	Traverse(SourceIter[T, S]) []T
}

Jump to

Keyboard shortcuts

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