DetectCompression detects the compression algorithm of the source.
(source []byte)
| 172 | |
| 173 | // DetectCompression detects the compression algorithm of the source. |
| 174 | func 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. |
| 187 | func DecompressStream(archive io.Reader) (DecompressReadCloser, error) { |
searching dependent graphs…