files

package
v0.0.0-...-2be0f72 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IgnoreDotAndTempFiles

func IgnoreDotAndTempFiles(_ string, fileInfo os.FileInfo) bool

IgnoreDotFiles returns true if the name starts with a ".". This is the default method for checking if an entry should be ignored.

func IsOfficeDocument

func IsOfficeDocument(mime string) bool

func NeverIgnore

func NeverIgnore(_ string, _ os.FileInfo) bool

NeverIgnore never ignores an entry.

Types

type IgnoreFunc

type IgnoreFunc func(path string, finfo os.FileInfo) bool

IgnoreFunc is a function definition that tells walkFiles when it should ignore files and directory paths.

type PWalker

type PWalker struct {
	// NumParallel is the number of go routines to start for processing.
	NumParallel int

	// ProcessFn is the function to use to process entries.
	ProcessFn ProcessFunc

	// IgnoreFn is the method to test if an entry should be ignored. If
	// IgnoreFn is nil then all entries will be process.
	IgnoreFn IgnoreFunc

	// ProcessDirs tells the walker whether directory entries should also
	// be passed to ProcessFn. It defaults to false, so by default directories
	// are not passed to ProcessFn.
	ProcessDirs bool
}

PWalker implements a parallel walker. It holds the options and processing methods to use during the walk.

func (*PWalker) PWalk

func (p *PWalker) PWalk(root string) (<-chan string, <-chan error)

PWalk will walk a tree and process files in it in parallel. fn is the process function. "n" go routines will be started with fn for processing. The ignorePathFn determines whether a file or directory path should be ignored. ignorePathFn can be nil. If it is nil then no files or paths are ignored.

type ProcessFunc

type ProcessFunc func(done <-chan struct{}, f <-chan TreeEntry, result chan<- string)

ProcessFunc is the signature for a function that processes each file entry.

type TreeEntry

type TreeEntry struct {
	Path  string
	Finfo os.FileInfo
}

A TreeEntry is passed along the channel to the process function.

Jump to

Keyboard shortcuts

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