Documentation ¶
Overview ¶
Package lzhuf implements the lzhuf compression used by the binary FBB protocols B, B1 and B2.
The compression is LZHUF with a CRC16 checksum of the compressed data prepended (B2F option).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrChecksum = errors.New("lzhuf: invalid checksum")
ErrChecksum indicates a checksum or file size mismatch on decode.
Functions ¶
This section is empty.
Types ¶
type Reader ¶ added in v0.7.0
type Reader struct {
// contains filtered or unexported fields
}
A Reader is an io.Reader that can be read to retrieve uncompressed data from a lzhuf-compressed file.
Lzhuf files store a length and optionally a checksum of the uncompressed data. The Reader will return io.ErrUnexpectedEOF when Read reaches the end of the uncompressed data. The checksum is verified on Close.
Clients should treat data returned by Read as tentative until they receive the io.EOF marking the end of the data. Data consistency should then be verified by calling Close.
func NewB2Reader ¶ added in v0.7.0
NewB2Reader creates a new Reader expecting the extended FBB B2 format used by Winlink.
It is the caller's responsibility to call Close on the Reader when done.
func NewReader ¶ added in v0.7.0
NewReader creates a new Reader reading the given reader.
If crc16 is true, the Reader will expect and verify a checksum of the compressed data (as per FBB B2).
It is the caller's responsibility to call Close on the Reader when done.
func (*Reader) Close ¶ added in v0.7.0
Close closes the Reader. It does not close the underlying io.Reader.
If an error was encountered during Read, the error will be returned. ErrChecksum is returned if the filesize header does not match the number of bytes read, or a crc16 checksum (B2 format) was expected but did not match.
If no error is returned, the file has been successfully decompressed.
type Writer ¶ added in v0.7.0
type Writer struct {
// contains filtered or unexported fields
}
A Writer is an io.WriteCloser. Writes to a Writer are compressed and writter to w.
func NewB2Writer ¶ added in v0.7.0
NewB2Writer returns a new Writer with the extended FBB B2 format used by Winlink.
It is the caller's responsibility to call Close on the WriteCloser when done. Writes may be buffered and not flushed until Close.
func NewWriter ¶ added in v0.7.0
NewWriter returns a new Writer. Writes to the returned writer are compressed and written to w.
If crc16 is true, the header will be prepended with a checksum of the compressed data (as per FBB B2).
It is the caller's responsibility to call Close on the WriteCloser when done. Writes may be buffered and not flushed until Close.