Package flate
import "compress/flate"
Package flate implements the DEFLATE compressed data format, described in RFC 1951. The gzip and zlib packages implement access to DEFLATE-based file formats.
Package files
deflate.go huffman_bit_writer.go huffman_code.go inflate.go reverse_bits.go token.go util.goConstants
const (
NoCompression = 0
BestSpeed = 1
BestCompression = 9
DefaultCompression = -1
)
func NewReader
func NewReader(r io.Reader) io.ReadCloser
NewReader returns a new ReadCloser that can be used to read the uncompressed version of r. It is the caller's responsibility to call Close on the ReadCloser when finished reading.
func NewReaderDict
func NewReaderDict(r io.Reader, dict []byte) io.ReadCloser
NewReaderDict is like NewReader but initializes the reader with a preset dictionary. The returned Reader behaves as if the uncompressed data stream started with the given dictionary, which has already been read. NewReaderDict is typically used to read data compressed by NewWriterDict.
type CorruptInputError
A CorruptInputError reports the presence of corrupt input at a given offset.
type CorruptInputError int64
func (CorruptInputError) String
func (e CorruptInputError) String() string
type InternalError
An InternalError reports an error in the flate code itself.
type InternalError string
func (InternalError) String
func (e InternalError) String() string
type ReadError
A ReadError reports an error encountered while reading input.
type ReadError struct {
Offset int64 // byte offset where error occurred
Error os.Error // error returned by underlying Read
}
func (*ReadError) String
func (e *ReadError) String() string
type Reader
The actual read interface needed by NewReader. If the passed in io.Reader does not also have ReadByte, the NewReader will introduce its own buffering.
type Reader interface {
io.Reader
ReadByte() (c byte, err os.Error)
}
type WriteError
A WriteError reports an error encountered while writing output.
type WriteError struct {
Offset int64 // byte offset where error occurred
Error os.Error // error returned by underlying Write
}
func (*WriteError) String
func (e *WriteError) String() string
type Writer
A Writer takes data written to it and writes the compressed form of that data to an underlying writer (see NewWriter).
type Writer struct {
// contains filtered or unexported fields
}
func NewWriter
func NewWriter(w io.Writer, level int) *Writer
NewWriter returns a new Writer compressing data at the given level. Following zlib, levels range from 1 (BestSpeed) to 9 (BestCompression); higher levels typically run slower but compress more. Level 0 (NoCompression) does not attempt any compression; it only adds the necessary DEFLATE framing.
func NewWriterDict
func NewWriterDict(w io.Writer, level int, dict []byte) *Writer
NewWriterDict is like NewWriter but initializes the new Writer with a preset dictionary. The returned Writer behaves as if the dictionary had been written to it without producing any compressed output. The compressed data written to w can only be decompressed by a Reader initialized with the same dictionary.
func (*Writer) Close
func (w *Writer) Close() os.Error
Close flushes and closes the writer.
func (*Writer) Flush
func (w *Writer) Flush() os.Error
Flush flushes any pending compressed data to the underlying writer. It is useful mainly in compressed network protocols, to ensure that a remote reader has enough data to reconstruct a packet. Flush does not return until the data has been written. If the underlying writer returns an error, Flush returns that error.
In the terminology of the zlib library, Flush is equivalent to Z_SYNC_FLUSH.
func (*Writer) Write
func (w *Writer) Write(data []byte) (n int, err os.Error)
Write writes data to w, which will eventually write the compressed form of data to its underlying writer.
type WrongValueError
type WrongValueError struct {
// contains filtered or unexported fields
}
func (WrongValueError) String
func (err WrongValueError) String() string