cgzip

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2016 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package cgzip wraps the C library for gzip.

Index

Constants

View Source
const (
	// Allowed flush values
	Z_NO_FLUSH      = 0
	Z_PARTIAL_FLUSH = 1
	Z_SYNC_FLUSH    = 2
	Z_FULL_FLUSH    = 3
	Z_FINISH        = 4
	Z_BLOCK         = 5
	Z_TREES         = 6

	// Return codes
	Z_OK            = 0
	Z_STREAM_END    = 1
	Z_NEED_DICT     = 2
	Z_ERRNO         = -1
	Z_STREAM_ERROR  = -2
	Z_DATA_ERROR    = -3
	Z_MEM_ERROR     = -4
	Z_BUF_ERROR     = -5
	Z_VERSION_ERROR = -6

	// compression levels
	Z_NO_COMPRESSION      = 0
	Z_BEST_SPEED          = 1
	Z_BEST_COMPRESSION    = 9
	Z_DEFAULT_COMPRESSION = -1

	// our default buffer size
	// most go io functions use 32KB as buffer size, so 32KB
	// works well here for compressed data buffer
	DEFAULT_COMPRESSED_BUFFER_SIZE = 32 * 1024
)

Variables

This section is empty.

Functions

func Adler32Combine

func Adler32Combine(adler1, adler2 uint32, len2 int) uint32

helper method for partial checksums. From the zlib.h header:

Combine two Adler-32 checksums into one.  For two sequences of bytes, seq1

and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.

func Crc32Combine

func Crc32Combine(crc1, crc2 uint32, len2 int) uint32

helper method for partial checksums. From the zlib.h header:

Combine two CRC-32 checksums into one.  For two sequences of bytes, seq1

and seq2 with lengths len1 and len2, CRC-32 checksums were calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 checksum of seq1 and seq2 concatenated, requiring only crc1, crc2, and len2.

func NewAdler32

func NewAdler32() hash.Hash32

an empty buffer has an adler32 of '1' by default, so start with that (the go hash/adler32 does the same)

func NewCrc32

func NewCrc32() hash.Hash32

an empty buffer has an crc32 of '1' by default, so start with that (the go hash/crc32 does the same)

func NewReader

func NewReader(r io.Reader) (io.ReadCloser, error)

func NewReaderBuffer

func NewReaderBuffer(r io.Reader, bufferSize int) (io.ReadCloser, error)

Types

type Writer

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

err starts out as nil we will call deflateEnd when we set err to a value: - whatever error is returned by the underlying writer - io.EOF if Close was called

func NewWriter

func NewWriter(w io.Writer) *Writer

func NewWriterLevel

func NewWriterLevel(w io.Writer, level int) (*Writer, error)

func NewWriterLevelBuffer

func NewWriterLevelBuffer(w io.Writer, level, bufferSize int) (*Writer, error)

func (*Writer) Close

func (z *Writer) Close() error

Calling Close does not close the wrapped io.Writer originally passed to NewWriterX.

func (*Writer) Flush

func (z *Writer) Flush() error

func (*Writer) Write

func (z *Writer) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL