reader

package
v0.87.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	FingerprintSize         int
	MaxLogSize              int
	Emit                    emit.Callback
	IncludeFileName         bool
	IncludeFilePath         bool
	IncludeFileNameResolved bool
	IncludeFilePathResolved bool
	DeleteAtEOF             bool
}

type Factory

type Factory struct {
	*zap.SugaredLogger
	Config          *Config
	FromBeginning   bool
	SplitterFactory splitter.Factory
	Encoding        encoding.Encoding
	HeaderConfig    *header.Config
}

func (*Factory) Copy

func (f *Factory) Copy(old *Reader, newFile *os.File) (*Reader, error)

copy creates a deep copy of a reader

func (*Factory) NewFingerprint

func (f *Factory) NewFingerprint(file *os.File) (*fingerprint.Fingerprint, error)

func (*Factory) NewReader

func (f *Factory) NewReader(file *os.File, fp *fingerprint.Fingerprint) (*Reader, error)

type Metadata

type Metadata struct {
	Fingerprint     *fingerprint.Fingerprint
	Offset          int64
	FileAttributes  map[string]any
	HeaderFinalized bool
}

type Reader

type Reader struct {
	*Config
	*Metadata
	FileName string
	// contains filtered or unexported fields
}

Reader manages a single file

func (*Reader) Close

func (r *Reader) Close()

Close will close the file

func (*Reader) NewFingerprintFromFile

func (r *Reader) NewFingerprintFromFile() (*fingerprint.Fingerprint, error)

func (*Reader) Read

func (r *Reader) Read(dst []byte) (int, error)

Read from the file and update the fingerprint if necessary

func (*Reader) ReadToEnd

func (r *Reader) ReadToEnd(ctx context.Context)

ReadToEnd will read until the end of the file

func (*Reader) ValidateOrClose

func (r *Reader) ValidateOrClose() bool

ValidateOrClose returns true if the reader still has a valid file handle, false otherwise. If false is returned, the file handle should be considered closed.

It may create a new fingerprint from the old file handle and compare it to the previously known fingerprint. If there has been a change to the fingerprint (other than appended data), the file is considered truncated. Consequently, the reader will automatically close the file and drop the handle.

Jump to

Keyboard shortcuts

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