fsutil

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2019 License: MIT Imports: 6 Imported by: 8

Documentation

Overview

Package fsutil adds ignore support for walk

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cwd

func Cwd() string

func DirExists

func DirExists(path string) bool

DirExists check if the path exists and it is a directory

func Exists

func Exists(path string) bool

Exists check if path exists and returns false regardless of detail error message

func FileExists

func FileExists(path string) bool

FileExists check if the path exists and it is a file, returns false regardless of detail error message i.e. it is possible the file exists but current reader doesn't have permission to read

func Walk

func Walk(root string, ignores *Ignores, walkFunc WalkFunc) error

Walk traverse the directory with ignore patterns in Pre-Order DFS

func WriteFile

func WriteFile(path string, data []byte) error

WriteFile use 0664 as permission and wrap standard error

Types

type ExactPattern

type ExactPattern string

func (ExactPattern) ShouldIgnore

func (p ExactPattern) ShouldIgnore(path string) bool

type IgnorePattern

type IgnorePattern interface {
	ShouldIgnore(path string) bool
}

type Ignores

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

func NewIgnores

func NewIgnores(names []IgnorePattern, paths []IgnorePattern) *Ignores

func (*Ignores) AddName

func (is *Ignores) AddName(name IgnorePattern)

func (*Ignores) AddPath

func (is *Ignores) AddPath(path IgnorePattern)

func (*Ignores) IgnoreName

func (is *Ignores) IgnoreName(name string) bool

func (*Ignores) IgnorePath

func (is *Ignores) IgnorePath(path string) bool

func (*Ignores) Len

func (is *Ignores) Len() int

func (*Ignores) Patterns

func (is *Ignores) Patterns() []IgnorePattern

func (*Ignores) SetPathPrefix

func (is *Ignores) SetPathPrefix(prefix string)

type WalkFunc

type WalkFunc func(path string, info os.FileInfo)

type WildcardPattern

type WildcardPattern string

Deprecated it is not implemented yet NOTE: only * and ? is supported * matches any non empty sequence of non-separator character ? matches one non-separator character we are NOT expecting path to have * and ?

func (WildcardPattern) ShouldIgnore

func (p WildcardPattern) ShouldIgnore(path string) bool

Jump to

Keyboard shortcuts

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