fscan

package
v0.0.0-...-86b5199 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RecommendedConcurrent = runtime.GOMAXPROCS(0) - 1
)

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Root string
	Path string
	FI   os.FileInfo
	Sha1 []byte
}

func (*Entry) GetFileInfo

func (se *Entry) GetFileInfo() os.FileInfo

func (*Entry) GetPath

func (se *Entry) GetPath() string

func (*Entry) GetRoot

func (se *Entry) GetRoot() string

func (*Entry) GetSha1

func (se *Entry) GetSha1() []byte

func (*Entry) GetSha1Hex

func (se *Entry) GetSha1Hex() (string, error)

func (*Entry) String

func (se *Entry) String() string

func (*Entry) UpdateSha1

func (se *Entry) UpdateSha1() error

type FileFilter

type FileFilter func(info os.FileInfo, fullPath string, searchingRoot string) (ok bool, err error)

* FileFilter is a function that determine is a file met some conditions. * * the `info` param can be null when `os.Lstat` of the given path failed * the `err` param will be passed to `path/filepath.Walk`

func FilterIgnoreHiddenFile

func FilterIgnoreHiddenFile() FileFilter

func FilterIgnoreNameTableOfFile

func FilterIgnoreNameTableOfFile(names ...string) FileFilter

func FilterIgnorePrefixTableOfFile

func FilterIgnorePrefixTableOfFile(prefix ...string) FileFilter

btw. redix-tree can handle a large scale of prefix matching

func FilterIgnorePrefixTableOfPath

func FilterIgnorePrefixTableOfPath(prefix ...string) FileFilter

func FilterIgnoreRegexOfPath

func FilterIgnoreRegexOfPath(strRegexMatch string) FileFilter

func FilterMatchRegexOfPath

func FilterMatchRegexOfPath(strRegexMatch string) FileFilter

type IScanEntry

type IScanEntry interface {
	GetRoot() string
	GetPath() string
	GetFileInfo() os.FileInfo
	GetSha1() []byte
	GetSha1Hex() (string, error)

	UpdateSha1() error
}

type IScanResult

type IScanResult interface {
	IScanner

	Len() int
	UsingRelativePath() bool

	Get(path string) IScanEntry
	GetPaths() []string

	RangeFiles(fn func(pth string, se IScanEntry) error) error
	RangeDirs(fn func(pth string, se IScanEntry) error) error

	WarmUp()
	GetChildrenTable() map[string][]string
}

func NewAndScan

func NewAndScan(searchingRoot string, usingRelativePath bool, middleWares ...FileFilter) (IScanResult, error)

func NewEmpty

func NewEmpty(searchingRoot string, usingRelativePath bool, middleWares ...FileFilter) (IScanResult, error)

type IScanner

type IScanner interface {
	GetRoot() string
	FireNew() (IScanResult, error)
}

type ScanResult

type ScanResult struct {
	Paths []string
	// contains filtered or unexported fields
}

func (*ScanResult) CalculateSha1

func (sr *ScanResult) CalculateSha1(errorHandler func(path string, err error)) *ScanResult

func (*ScanResult) CalculateSha1Concurrently

func (sr *ScanResult) CalculateSha1Concurrently(concurrent int, errorHandler func(path string, err error)) *ScanResult

func (*ScanResult) FireNew

func (sr *ScanResult) FireNew() (IScanResult, error)

FireNew :: immutable - to create a new scan result with given sr

func (*ScanResult) Get

func (sr *ScanResult) Get(path string) IScanEntry

func (*ScanResult) GetChildrenTable

func (sr *ScanResult) GetChildrenTable() map[string][]string

func (*ScanResult) GetPaths

func (sr *ScanResult) GetPaths() []string

func (*ScanResult) GetRoot

func (sr *ScanResult) GetRoot() string

func (*ScanResult) Len

func (sr *ScanResult) Len() int

func (*ScanResult) RangeDirs

func (sr *ScanResult) RangeDirs(fn func(pth string, se IScanEntry) error) error

func (*ScanResult) RangeFiles

func (sr *ScanResult) RangeFiles(fn func(pth string, se IScanEntry) error) error

func (*ScanResult) UsingRelativePath

func (sr *ScanResult) UsingRelativePath() bool

func (*ScanResult) WarmUp

func (sr *ScanResult) WarmUp()

WarmUp all sha1 codes concurrently

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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