MCPcopy
hub / github.com/containerd/containerd / DetectCompression

Function DetectCompression

pkg/archive/compression/compression.go:174–184  ·  view source on GitHub ↗

DetectCompression detects the compression algorithm of the source.

(source []byte)

Source from the content-addressed store, hash-verified

172
173// DetectCompression detects the compression algorithm of the source.
174func DetectCompression(source []byte) Compression {
175 for compression, fn := range map[Compression]matcher{
176 Gzip: magicNumberMatcher(gzipMagic),
177 Zstd: zstdMatcher(),
178 } {
179 if fn(source) {
180 return compression
181 }
182 }
183 return Uncompressed
184}
185
186// DecompressStream decompresses the archive and returns a ReaderCloser with the decompressed archive.
187func DecompressStream(archive io.Reader) (DecompressReadCloser, error) {

Callers 3

detectLayerMediaTypeFunction · 0.92
DecompressStreamFunction · 0.85

Calls 2

magicNumberMatcherFunction · 0.85
zstdMatcherFunction · 0.85

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…