input

package
Version: v0.0.0-...-e96a773 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2016 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Overview

TODO Write tests

TODO Write tests

Package input provides various Input implementations for reading from []byte or os.File.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadAndDiscard

func ReadAndDiscard(r io.Reader, len int64) (int, error)

ReadAndDiscard reads len bytes from the file, and discards them.

func ReadFullAt

func ReadFullAt(r io.ReaderAt, buf []byte, off int64) (n int, err error)

func ReadUntil

func ReadUntil(r io.ByteReader, delim byte, maxLen int64) (int64, error)

ReadUntil reads from the file until it finds a delim byte, EOF, or len bytes have been checked. Returning the number of bytes if the delimitor was found, or 0 and a error. io.ErrUnexpectedEOF is returned if the EOF was found.

Types

type Bytes

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

Bytes implements Input

func FromBytes

func FromBytes(bytes []byte) *Bytes

func (*Bytes) Read

func (f *Bytes) Read(b []byte) (int, error)

func (*Bytes) ReadAt

func (f *Bytes) ReadAt(b []byte, off int64) (int, error)

func (*Bytes) ReadByte

func (f *Bytes) ReadByte() (byte, error)

func (*Bytes) Seek

func (f *Bytes) Seek(offset int64, whence int) (int64, error)

func (*Bytes) Tell

func (f *Bytes) Tell() (int64, error)

type Input

type Input interface {
	io.Seeker

	io.Reader
	io.ReaderAt
	io.ByteReader

	Tell() (int64, error) // Here for convenience, perhaps remove.
}

Input interface provides the minimum methods needed to parse a binary file. The interface is changed slightly, by ensuring the Read methods always try to do a full read. If they are unable to read the full amount, then a ShortReadError is returned, as well as as much as could be read.

type OSFile

type OSFile os.File

OSFile implements ufwb.File by wrapping a os.File

func FromOSFile

func FromOSFile(f *os.File) *OSFile

func OpenOSFile

func OpenOSFile(filename string) (*OSFile, error)

func (*OSFile) Close

func (f *OSFile) Close() error

func (*OSFile) Read

func (f *OSFile) Read(b []byte) (int, error)

func (*OSFile) ReadAt

func (f *OSFile) ReadAt(b []byte, off int64) (int, error)

func (*OSFile) ReadByte

func (f *OSFile) ReadByte() (byte, error)

func (*OSFile) Seek

func (f *OSFile) Seek(offset int64, whence int) (int64, error)

func (*OSFile) Tell

func (f *OSFile) Tell() (int64, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL