Documentation
¶
Overview ¶
Package trackedoffset provides readers and writers that will keep track of the current offset as data is being read or written to and from.
Index ¶
- type File
- func (f *File) Close() error
- func (f *File) Discard(n int) (int, error)
- func (f *File) File() *os.File
- func (f *File) Flush() error
- func (f *File) Name() string
- func (f *File) Offset() uint64
- func (f *File) Peek(n int) ([]byte, error)
- func (f *File) Read(p []byte) (int, error)
- func (f *File) ReadByte() (byte, error)
- func (f *File) ReadRune() (rune, int, error)
- func (f *File) Reader() *bufio.Reader
- func (f *File) ResetReadBuffer()
- func (f *File) ResetWriteBuffer()
- func (f *File) Seek(offset int64, whence int) (int64, error)
- func (f *File) SetOffset(newOffset uint64)
- func (f *File) Stat() (os.FileInfo, error)
- func (f *File) Sync() error
- func (f *File) SyncOffset() error
- func (f *File) UnreadByte() error
- func (f *File) Write(p []byte) (int, error)
- func (f *File) WriteByte(c byte) error
- func (f *File) WriteRune(r rune) (int, error)
- func (f *File) Writer() *bufio.Writer
- type Reader
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File wraps an os.File and keeps track of the current offset without requiring constant calls to Seek which involves syscall Lseek to be made. Reading and Writing is buffered by using the bufio package. Implements the following interfaces: io.Reader, io.Writer, io.Seeker, io.ByteReader.
func OpenFile ¶
Wraps os.OpenFile to allow for more options.
func (*File) Discard ¶ added in v0.2.0
Skips the next n bytes, returning the number of bytes discarded.
func (*File) Peek ¶ added in v0.2.0
Peek returns the next n bytes without advancing the offset or the reader. See bufio.Reader.Peek.
func (*File) ReadRune ¶ added in v0.2.0
Reads a single UTF-8 encoded Unicode character and returns the rune and its size in bytes. If the encoded rune is invalid, it consumes one byte and returns unicode.ReplacementChar (U+FFFD) with a size of 1.
func (*File) ResetReadBuffer ¶
func (f *File) ResetReadBuffer()
Discard any buffered data that has not yet been read. Ensure you call this if you have changed the current offset using Seek.
func (*File) ResetWriteBuffer ¶
func (f *File) ResetWriteBuffer()
Discard any buffered data that has not yet been written. Ensure you call this if you have changed the current offset using Seek.
func (*File) SyncOffset ¶
Ensure the File's offset and the underlying os.File's actual offsets are the same. This will make a call to file.Seek.
func (*File) UnreadByte ¶ added in v0.2.0
Unreads the last byte. Only the most recently read byte can be unread. See [bufio.Reader. UnreadByte].
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader keeps track of the offset within an io.Reader source.
func NewReader ¶
Create a new Reader that will keep track of the offset within the source io.Reader. baseOffset is the known starting offset.
func (*Reader) ResetOffset ¶
Set the known offset in bytes.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer keeps track of the offset within an io.Writer source.
func NewWriter ¶
Create a new Writer that will keep track of the offset within the source io.Writer.
func (*Writer) ResetOffset ¶
Set the known offset in bytes.