package
0.0.0-20221003172846-a3e1774ef349
Repository: https://github.com/dsoprea/go-utility.git
Documentation: pkg.go.dev

# README

GoDoc Build Status Coverage Status Go Report Card

bounceback

An io.ReadSeeker and io.WriteSeeker that returns to the right place before reading or writing. Useful when the same file resource is being reused for reads or writes throughout that file.

list_files

A recursive path walker that supports filters.

seekable_buffer

A memory structure that satisfies io.ReadWriteSeeker.

copy_bytes_between_positions

Given an io.ReadWriteSeeker, copy N bytes from one position to an earlier position.

read_counter, write_counter

Wrap io.Reader and io.Writer structs in order to report how many bytes were transferred.

readseekwritecloser

Provides the ReadWriteSeekCloser interface that combines a RWS and a Closer. Also provides a no-op wrapper to augment a plain RWS with a closer.

boundedreadwriteseek

Wraps a ReadWriteSeeker such that no seeks can be at an offset less than a specific-offset.

calculateseek

Provides a reusable function with which to calculate seek offsets.

progress_wrapper

Provides io.Reader and io.Writer wrappers that also trigger callbacks after each call. The reader wrapper also invokes the callback upon EOF.

does_exist

Check whether a file/directory exists using a file-path.

graceful_copy

Do a copy but correctly handle short-writes and reads that might return a non- zero read count and EOF.

readseeker_to_readerat

A wrapper that allows an io.ReadSeeker to be used as a io.ReaderAt.

simplefileinfo

An implementation of os.FileInfo to support testing.

# Functions

CalculateSeek calculates an offset in a file-stream given the parameters.
CopyBytesBetweenPositions will copy bytes from one position in the given RWS to an earlier position in the same RWS.
DoesExist returns true if we can open the given file/path without error.
GetOffset returns the current offset of the Seeker and just panics if unable to find it.
GracefulCopy willcopy while enduring lesser normal issues.
ListFiles feeds a continuous list of files from a recursive folder scan.
NewBouncebackReader returns a `*BouncebackReader` struct.
NewBouncebackWriter returns a new `BouncebackWriter` struct.
NewBoundedReadWriteSeekCloser returns a new BoundedReadWriteSeekCloser.
NewBoundedReadWriteSeeker returns a new BoundedReadWriteSeeker instance.
NewReadCounter returns a new `ReadCounter` struct wrapping a `Reader`.
NewReadProgressWrapper returns a new RPW instance.
NewReadSeekerToReaderAt returns a new ReadSeekerToReaderAt instance.
NewSeekableBuffer is a factory that returns a `*SeekableBuffer`.
NewSeekableBufferWithBytes is a factory that returns a `*SeekableBuffer`.
NewSimpleFileInfoWithDirectory returns a new directory-specific SimpleFileInfo.
NewSimpleFileInfoWithFile returns a new file-specific SimpleFileInfo.
NewWriteCounter returns a new `WriteCounter` struct wrapping a `Writer`.
NewWriteProgressWrapper returns a new WPW instance.
ReadWriteSeekNoopCloser wraps a `io.ReadWriteSeeker` with a no-op Close() call.

# Variables

ErrSeekBeyondBound is returned when a seek is requested beyond the statically-given file-size.

# Structs

BouncebackReader wraps a ReadSeeker, keeps track of our position, and seeks back to it before writing.
BouncebackStats describes operation counts.
BouncebackWriter wraps a WriteSeeker, keeps track of our position, and seeks back to it before writing.
BoundedReadWriteSeekCloser wraps a RWS that is also a closer with boundaries.
BoundedReadWriteSeeker is a thin filter that ensures that no seeks can be done to offsets smaller than the one we were given.
ReadCounter proxies read requests and maintains a counter of bytes read.
ReadProgressWrapper wraps a reader and calls a callback after each read with count and duration info.
ReadSeekerToReaderAt is a wrapper that allows a ReadSeeker to masquerade as a ReaderAt.
SeekableBuffer is a simple memory structure that satisfies `io.ReadWriteSeeker`.
SimpleFileInfo is a simple `os.FileInfo` implementation useful for testing with the bare minimum.
VisitedFile is one visited file.
WriteCounter proxies write requests and maintains a counter of bytes written.
WriteProgressWrapper wraps a reader and calls a callback after each read with count and duration info.

# Interfaces

ReadWriteSeekCloser satisfies `io.ReadWriteSeeker` and `io.Closer` interfaces.

# Type aliases

FileListFilterPredicate is the callback predicate used for filtering.
ProgressFunc receives progress updates.
SeekType is a convenience type to associate the different seek-types with printable descriptions.