1
0
This repository has been archived on 2025-03-04. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Matheus Sampaio Queiroga 0df872b33c
Some checks failed
Build / build (mipsle) (push) Waiting to run
Build / build (ppc64) (push) Waiting to run
Build / build (ppc64le) (push) Waiting to run
Build / build (riscv64) (push) Waiting to run
Build / build (s390x) (push) Waiting to run
Build / build (amd64) (push) Has been cancelled
Build / build (386) (push) Has been cancelled
Build / build (mips64le) (push) Has been cancelled
Build / build (arm) (push) Has been cancelled
Build / build (mips64) (push) Has been cancelled
Build / build (mips) (push) Has been cancelled
Build / build (loong64) (push) Has been cancelled
Build / build (arm64) (push) Has been cancelled
update release
Signed-off-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
2025-03-04 17:59:41 -03:00

37 lines
704 B
Go

package dpkg
import (
"bytes"
"io"
)
func compressExt(r io.Reader) (string, io.Reader, error) {
// Read fist bytes to detect file compression
buf := make([]byte, 15)
if _, err := r.Read(buf); err != nil {
return "", r, err
}
// Concat read bytes
r = io.MultiReader(bytes.NewReader(buf), r)
switch {
// Gzip
case bytes.HasPrefix(buf, []byte{0x1F, 0x8B, 0x08}):
return ".gz", r, nil
// BZip2
case bytes.HasPrefix(buf, []byte{0x5A, 0x42}):
return ".bz2", r, nil
// XZ
case bytes.HasPrefix(buf, []byte{0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00}):
return ".xz", r, nil
// Zstd
case bytes.HasPrefix(buf, []byte{0xB5, 0x28, 0xFD, 0x2F}):
return ".zst", r, nil
}
return "", r, nil
}