MCPcopy
hub / github.com/klauspost/compress / ZipCompressor

Function ZipCompressor

zstd/zip.go:117–132  ·  view source on GitHub ↗

ZipCompressor returns a compressor that can be registered with zip libraries. The provided encoder options will be used on all encodes.

(opts ...EOption)

Source from the content-addressed store, hash-verified

115// ZipCompressor returns a compressor that can be registered with zip libraries.
116// The provided encoder options will be used on all encodes.
117func ZipCompressor(opts ...EOption) func(w io.Writer) (io.WriteCloser, error) {
118 var pool sync.Pool
119 return func(w io.Writer) (io.WriteCloser, error) {
120 enc, ok := pool.Get().(*Encoder)
121 if ok {
122 enc.Reset(w)
123 } else {
124 var err error
125 enc, err = NewWriter(w, opts...)
126 if err != nil {
127 return nil, err
128 }
129 }
130 return &pooledZipWriter{enc: enc, pool: &pool}, nil
131 }
132}
133
134// ZipDecompressor returns a decompressor that can be registered with zip libraries.
135// See ZipCompressor for example.

Callers 1

ExampleZipCompressorFunction · 0.92

Calls 2

NewWriterFunction · 0.70
ResetMethod · 0.65

Tested by 1

ExampleZipCompressorFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…