walk

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: MPL-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const DefaultScratchBufferSize = 64 * 1024

DefaultScratchBufferSize specifies the size of the scratch buffer that will be allocated by Walk

Variables

View Source
var (
	ErrNonDir = errors.New("walk: Cannot iterate non-directory")
)

Errors

Functions

func Walk

func Walk(root string, options *Options) error

Walk walks the file tree rooted at the specified directory, calling the specified callback function for each file system node in the tree, including root, symbolic links, and other node types.

Types

type Dirent

type Dirent struct {
	// contains filtered or unexported fields
}

Dirent stores a single directory entry (see getDirents)

func (Dirent) IsDir

func (d Dirent) IsDir() bool

IsDir reports whether i describes a directory.

func (Dirent) IsRegular

func (d Dirent) IsRegular() bool

IsRegular reports whether i describes a regular file.

func (d Dirent) IsSymlink() bool

IsSymlink reports whether i describes a symbolic link.

func (Dirent) Name

func (d Dirent) Name() string

Name of the directory entry

type ErrorHandler

type ErrorHandler func(dir string, entry *Dirent, err error) error

ErrorHandler callback function

type Options

type Options struct {
	// Invoked before entering a (sub)directory.
	Enter Visitor

	// Invoked for every encountered directory entry.
	Visit Visitor

	// Invoked after leaving a (sub)directory.
	Leave ErrorHandler

	// Invoked on error.
	Error ErrorHandler

	// ScratchBuffer is an optional byte slice to use as a scratch buffer.
	ScratchBuffer []byte
}

Options provide parameters for how the Walk function operates.

type Visitor

type Visitor func(dir string, entry *Dirent) error

Visitor callback function

Jump to

Keyboard shortcuts

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