Documentation ¶
Index ¶
Constants ¶
const ( // FilteredStrategy stands for C.Z_FILTERED FilteredStrategy = 1 // HuffmanOnlyStrategy stands for C.Z_HUFFMAN_ONLY HuffmanOnlyStrategy = 2 // RLEStrategy stands for C.Z_RLE RLEStrategy = 3 // FixedStrategy stands for C.Z_FIXED FixedStrategy = 4 // DefaultStrategy stands for C.Z_DEFAULT_STRATEGY DefaultStrategy = 0 )
Strategy values
const ( // Gzip is the value of Opts.WindowBits to use FLATE format as defined in RFC1952 Gzip = 16 + 15 // Flate should is the value of Opts.WindowBits to use FLATE format as defined in RFC1951 Flate = -15 )
const DefaultBufferSize = 512 * 1024
DefaultBufferSize is the default value of Opts.Buffer
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GzipHeader ¶
type GzipHeader struct { Comment string Extra []byte ModTime time.Time Name string // OS field, cf. RFC1952 Section 2.3. Default: 255 OS byte }
GzipHeader alters the contents the gzip header. It is stored in Opts.GzipHeader to control the contents of the header.
TODO(saito) Support other fields if needed.
type Opts ¶
type Opts struct { // WindowBits specifies the windowBits arg for deflateInit and inflateInit. It // specifies the compression window size as well as the header format. If // unset, Gzip is used. WindowBits int // Buffer specifies the internal buffer size used during compression and // decompression. The default value is 512KiB. Buffer int // Level specifies the compression level, used only by the writer. // The default value of 0 means no compression, which is probably not what you want. // -1 is the default compression level. If you don't pass any Opts to NewWriter, // it will use -1 as the value. Level int // MemLevel specifies the memLevel arg for deflateInit2. If unset, value of 8 // is used. MemLevel int // Strategy specifies the strategy arg for deflateInit. If unset, // Z_DEFAULT_STRATEGY is used. Strategy int }
Opts define the options passed to NewReader and NewWriter.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is a gzip/zlib/flate reader. It implements io.ReadCloser. Calling Close is optional, though strongly recommended. NewReader() also installs a GC finalizer that closes the Reader, in case the application forgets to call Close.
func (*Reader) Header ¶
func (z *Reader) Header() (GzipHeader, error)
Header reads the gzip header contents. If the file is a multi-gzip concatenation, this function returns the contents of the current archive.
REQUIRES: Opts.GetGzipHeader=true when the reader was created.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is the gzip/flate writer. It implements io.WriterCloser.
func NewWriter ¶
NewWriter creates a gzip/flate writer. There can be at most one options arg. If opts is empty, NewWriter will use Opts{Format:Gzip,Level:-1}.
func (*Writer) SetHeader ¶
func (z *Writer) SetHeader(h GzipHeader) error
SetHeader sets the Gzip header contents.
REQUIRES: No Write nor Close has been called yet. REQUIRES: The archive format is Gzip.