file

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2022 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Overview

Package file provides file system support, including file system walking

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MimeType

func MimeType(data []byte) (string, string, error)

MimeType returns the mimetype of the data, and returns the mimetype, file extension

Types

type VisitFunc

type VisitFunc func(ctx context.Context, abspath string, relpath string, info fs.FileInfo) error

VisitFunc is a function which is called for each file and folder visited. The function should return an error if the walk should be terminated.

type WalkFS

type WalkFS struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewWalker

func NewWalker(fn VisitFunc) *WalkFS

Create a new walkfs with a given visitor function, which is used for touching each visited file and folder

func (*WalkFS) Count

func (walkfs *WalkFS) Count() int

Count the number of files and folders visited

func (*WalkFS) Exclude

func (walkfs *WalkFS) Exclude(v string) error

Exclude adds a path or file extension exclusion to the indexer. If it begins with a '.' then a file extension exlusion is added, If it begins with a '/' then a path extension exclusion is added. Path and name exclusions are case-sensitive, file extension exclusions are not.

func (*WalkFS) Include

func (walkfs *WalkFS) Include(ext string) error

Include adds a file extension inclusion to the indexer. Path exclusions are case-sensitive, file extension exclusions are not. If no inclusions are added, all files are visited

func (*WalkFS) ShouldVisit

func (walkfs *WalkFS) ShouldVisit(relpath string, info fs.FileInfo) bool

ShouldVisit returns true if a path or file should be visited based on exclusions or else returns false

func (*WalkFS) Walk

func (walkfs *WalkFS) Walk(ctx context.Context, path string) error

Walk will walk a file or folder and visit the function for each

Jump to

Keyboard shortcuts

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