find

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Fields = [...]string{
	fieldName,
	fieldPath,
	fieldContainer,
	fieldSize,
	fieldDate,
	fieldTime,
	fieldExt,
	fieldExt2,
	fieldType,
	fieldArchive,
}

Fields is a slice of the constants that address fields in the FileInfo type.

Functions

func Walk

func Walk(root string, param WalkParams)

Walk is a function that performs a file search starting at the given root directory. See WalkParams to control the behavior of the search.

Types

type FileInfo

type FileInfo struct {
	Name      string
	Path      string
	ModTime   time.Time
	Size      int64
	Type      string
	Container string
	Archive   string
}

FileInfo is a type that represents information about a file or directory.

func (FileInfo) Context

func (file FileInfo) Context() filter.VariableGetter

Context is a method of the FileInfo type that returns a VariableGetter function that can be used to retrieve the values of the fields of the file or directory represented by the FileInfo instance.

It also generates helper properties like "today".

func (FileInfo) IsDir

func (fi FileInfo) IsDir() bool

IsDir returns a boolean value indicating if the FileInfo instance is a directory.

type FindError added in v0.4.1

type FindError struct {
	Path string
	Err  error
}

FindError is a type that represents an error that occurred during a file search.

func (*FindError) Error added in v0.4.1

func (e *FindError) Error() string

type WalkError added in v0.4.1

type WalkError struct {
	Path string
	Err  error
}

func (*WalkError) Error added in v0.4.1

func (e *WalkError) Error() string

type WalkFunc

type WalkFunc func(file *FileInfo, err error)

type WalkParams

type WalkParams struct {
	// Chan is the channel that is used to send the results of the search.
	Chan chan FileInfo
	// Err is the channel that is used to send error messages.
	Err chan string
	// Filter is the filter expression that is used to filter the results of the search.
	Filter *filter.FilterExpression
	// FollowSymlinks specifies whether symbolic links should be followed during the search.
	FollowSymlinks bool
	// NoArchive specifies whether archives should be skipped during the search.
	NoArchive bool
}

WalkParams is used to specify the parameters for a file search.

Jump to

Keyboard shortcuts

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