files

package
Version: v0.0.0-...-cae3ad5 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package files contains functions and types that help with file and directory processing.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotDirectory error
)

Errors returned by the files packages

Functions

func GetFileMd5

func GetFileMd5(ff string) string

Types

type DirMode

type DirMode uint32

A DirMode represents flags that define the behavior of the DirReader.

const (
	N_RECURSE DirMode = 0
	D_RECURSE DirMode = 1 << iota // Recurse all subdirectories
)

type DirReader

type DirReader struct {
	Filter Filter
	// contains filtered or unexported fields
}

A DirReader iterates through the files and subdirectories contained within a directory.

func NewDirReader

func NewDirReader(dir string, mode DirMode) (*DirReader, error)

NewDirReader creates a DirReader rooted at the specified directory.

func (*DirReader) Next

func (r *DirReader) Next() (*FileInfo, error)

Next iterates to the next available file in the directory and returns its FileInfo. Returns a nil FileInfo when complete.

type FileInfo

type FileInfo struct {
	Path string
	os.FileInfo
}

A FileInfo contains a file's full path. It also embeds an os.FileInfo.

type Filter

type Filter interface {
	Eval(f *FileInfo) bool
}

A Filter interface is used to define rules to include or exclude a file in the results of a Next() iteration.

func DirFilter

func DirFilter() Filter

DirFilter creates a filter that accepts only directories (not files).

func FileFilter

func FileFilter() Filter

FileFilter creates a filter that accepts only files (not directories).

func MultiFilter

func MultiFilter(filters ...Filter) Filter

MultiFilter creates a filter composed of several other filters.

func RegexpFilter

func RegexpFilter(pattern string) Filter

RegexpFilter creates a filter that returns true when the regular expression matches the file's full path.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL