file

package
v6.2.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Glob

func Glob(pattern string, doubleStarPatternDepth uint8) ([]string, error)

Glob expands '**' patterns into multiple patterns to satisfy https://golang.org/pkg/path/filepath/#Match

func GlobPatterns

func GlobPatterns(pattern string, doubleStarPatternDepth uint8) ([]string, error)

GlobPatterns detects the use of "**" and expands it to standard glob patterns up to a max depth

func IsSameFile

func IsSameFile(path string, info os.FileInfo) bool

IsSameFile checks if the given File path corresponds with the FileInfo given

Types

type File

type File struct {
	File     *os.File
	FileInfo os.FileInfo
	Path     string
	State    *State
}

func (*File) IsSameFile

func (f *File) IsSameFile(f2 *File) bool

Checks if the two files are the same.

type State

type State struct {
	Id          string        `json:"-"` // local unique id to make comparison more efficient
	Finished    bool          `json:"-"` // harvester state
	Fileinfo    os.FileInfo   `json:"-"` // the file info
	Source      string        `json:"source"`
	Offset      int64         `json:"offset"`
	Timestamp   time.Time     `json:"timestamp"`
	TTL         time.Duration `json:"ttl"`
	Type        string        `json:"type"`
	FileStateOS file.StateOS
}

State is used to communicate the reading state of a file

func NewState

func NewState(fileInfo os.FileInfo, path string, t string) State

NewState creates a new file state

func (*State) ID

func (s *State) ID() string

ID returns a unique id for the state as a string

func (*State) IsEmpty

func (s *State) IsEmpty() bool

IsEmpty returns true if the state is empty

func (*State) IsEqual

func (s *State) IsEqual(c *State) bool

IsEqual compares the state to an other state supporing stringer based on the unique string

type States

type States struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

States handles list of FileState

func NewStates

func NewStates() *States

func (*States) Cleanup

func (s *States) Cleanup() int

Cleanup cleans up the state array. All states which are older then `older` are removed The number of states that were cleaned up is returned

func (*States) Copy

func (s *States) Copy() *States

Copy create a new copy of the states object

func (*States) Count

func (s *States) Count() int

Count returns number of states

func (*States) FindPrevious

func (s *States) FindPrevious(newState State) State

func (*States) GetStates

func (s *States) GetStates() []State

Returns a copy of the file states

func (*States) SetStates

func (s *States) SetStates(states []State)

SetStates overwrites all internal states with the given states array

func (*States) Update

func (s *States) Update(newState State)

Update updates a state. If previous state didn't exist, new one is created

Jump to

Keyboard shortcuts

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