Skip to content

nickvanw/cbzip2

Repository files navigation

cbzip2

import "github.com/nickvanw/cbzip2"

Build Status

package cbzip2 provides access to the "low level" bzip2 interface via bzlib.h, documented here: a href="http://www.bzip.org/1.0.3/html/low-level.html">http://www.bzip.org/1.0.3/html/low-level.html

Constants

const (
    // valid actions
    BZ_RUN    = 0
    BZ_FLUSH  = 1
    BZ_FINISH = 2

    // return codes
    BZ_OK               = 0
    BZ_RUN_OK           = 1
    BZ_FLUSH_OK         = 2
    BZ_FINISH_OK        = 3
    BZ_STREAM_END       = 4
    BZ_SEQUENCE_ERROR   = (-1)
    BZ_PARAM_ERROR      = (-2)
    BZ_MEM_ERROR        = (-3)
    BZ_DATA_ERROR       = (-4)
    BZ_DATA_ERROR_MAGIC = (-5)
    BZ_IO_ERROR         = (-6)
    BZ_UNEXPECTED_EOF   = (-7)
    BZ_OUTBUFF_FULL     = (-8)
    BZ_CONFIG_ERROR     = (-9)
)

copied from bzlib.h

Variables

var (
    ErrBadParam       = errors.New("bad param (should be impossible)")
    ErrBadData        = errors.New("integrity problem detected in input data")
    ErrBadMagic       = errors.New("compressed stream does not being with magic bytes")
    ErrMem            = errors.New("insufficient memory available ಠ_ಠ")
    ErrInit           = errors.New("unable to initialize bzlib.h")
    ErrBadCompression = errors.New("unable to compress data")
)

type Reader

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

func NewReader

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

NewReader returns an io.ReadCloser. Reads from this are read from the underlying io.Reader and decompressed via bzip2

func (*Reader) Close

func (r *Reader) Close() error

Close closes the reader, but not the underlying io.Reader

func (*Reader) Read

func (r *Reader) Read(p []byte) (int, error)

Read pulls data up from the underlying io.Reader and decompresses the data

type Writer

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

func NewWriter

func NewWriter(w io.Writer) (*Writer, error)

NewWriter returns an io.WriteCloser. Writes to this writer are compressed and sent to the underlying writer. It is the caller's responsibility to call Close on the WriteCloser. Writes may not be flushed until Close.

func (*Writer) Close

func (b *Writer) Close() error

Close closes the writer, flushing any unwritten data to the underlying io.Writer Close does not close the underlying io.Writer.

func (*Writer) Flush

func (b *Writer) Flush() error

Flush writes any pending data to the underlying writer.

func (*Writer) Write

func (b *Writer) Write(d []byte) (int, error)

Write writes a compressed p to an underlying io.Writer. The bytes are not necessarily flushed until the writer is closed or Flush is called.


Generated by godoc2md

About

Go bzip2 reader/writer using cgo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published