traverse

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ItemAddStat = iota
	ItemOverStat
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DirTraverse

type DirTraverse struct {
	Path string

	Over      chan struct{}
	WorkSheet *WorkSheet

	ProcessFunc func(item *TraverseItem) // 重命名:Fc -> ProcessFunc
	// contains filtered or unexported fields
}

func NewDirTraverse

func NewDirTraverse(p string, processFunc func(item *TraverseItem), opts ...Option) *DirTraverse

func (*DirTraverse) Cancel added in v0.0.5

func (t *DirTraverse) Cancel()

Cancel 取消遍历操作

func (*DirTraverse) Close added in v0.0.5

func (t *DirTraverse) Close() error

Close 清理所有资源

func (*DirTraverse) Errors added in v0.0.5

func (t *DirTraverse) Errors() []error

Errors 返回遍历过程中收集的所有错误

func (*DirTraverse) GetAllPath

func (t *DirTraverse) GetAllPath(opts ...Option) ([]string, error)

func (*DirTraverse) Handle

func (t *DirTraverse) Handle(opts ...Option) error

func (*DirTraverse) HasErrors added in v0.0.5

func (t *DirTraverse) HasErrors() bool

HasErrors 检查是否有错误

func (*DirTraverse) SetOption

func (t *DirTraverse) SetOption(opts ...Option)

func (*DirTraverse) WaitOver

func (t *DirTraverse) WaitOver()

type FileCountRes

type FileCountRes struct {
	Count       int
	TargetCount int
	CountMap    map[string]int
	// contains filtered or unexported fields
}

func GetFileCount

func GetFileCount(dir string, opts ...Option) (*FileCountRes, error)

type FileListRes

type FileListRes struct {
	List []string
	Map  map[string]struct{}
	// contains filtered or unexported fields
}

func GetFileList

func GetFileList(dir string, opts ...Option) (*FileListRes, error)

type Option

type Option func(o *option)

func WithDefaultExclude

func WithDefaultExclude() Option

func WithDepth

func WithDepth(depth int) Option

func WithExcludeDir

func WithExcludeDir(exclude []string) Option

func WithExcludePrefix

func WithExcludePrefix(list ...string) Option

func WithExcludeSuffix

func WithExcludeSuffix(list ...string) Option

func WithExcludeUnknown

func WithExcludeUnknown(exclude bool) Option

func WithOnlyDir

func WithOnlyDir() Option

func WithProgressBarOut

func WithProgressBarOut() Option

func WithSyncFileOpMode

func WithSyncFileOpMode() Option

func WithSyncMode

func WithSyncMode() Option

func WithTargetExt

func WithTargetExt(ext string) Option

func WithWorkerCount

func WithWorkerCount(count int) Option

type Sheet

type Sheet map[string]bool

the map[string]bool, "" item is self the name like path,name must unique

type TraverseItem

type TraverseItem struct {
	FileInfo fs.FileInfo // 重命名:Fs -> FileInfo
	IsDir    bool
	FilePath string
	Path     string
	Parent   string
	Ext      string
	Depth    int
}

type WorkSheet

type WorkSheet struct {
	Sheet Sheet
	Over  bool

	WithProgressBarOut bool

	Count     int64
	OverCount int64
	// contains filtered or unexported fields
}

func NewWorkSheet

func NewWorkSheet() *WorkSheet

func (*WorkSheet) IsOver

func (w *WorkSheet) IsOver() bool

func (*WorkSheet) ItemAdd

func (w *WorkSheet) ItemAdd(path string)

func (*WorkSheet) ItemOver

func (w *WorkSheet) ItemOver(path string)

func (*WorkSheet) TraverseOver

func (w *WorkSheet) TraverseOver()

func (*WorkSheet) Wait

func (w *WorkSheet) Wait()

Jump to

Keyboard shortcuts

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