module Info ( identify ) where import Compression import Data.ByteString as BS identify :: BS.ByteString -> Compression identify bs | lzipMagicBytes `isPrefixOf` bs = Lzip | lzopMagicBytes `isPrefixOf` bs = Lzo #ifdef SNAPPY | snappyStreamIdentifier `isPrefixOf` bs = Snappy #endif | lz4Magic `isPrefixOf` bs = Lz4 | gzipId `isPrefixOf` bs = GZip | xzMagic `isPrefixOf` bs = Lzma | zstdMagic `isPrefixOf` bs = Zstd | bzMagic `isPrefixOf` bs = BZip | otherwise = None -- lrzipMagic :: BS.ByteString -- lrzipMagic = BS.pack [0x4c, 0x52, 0x5a, 0x49] zstdMagic :: BS.ByteString zstdMagic = BS.pack [0x28, 0xb5, 0x2f, 0xfd] lzipMagicBytes :: BS.ByteString lzipMagicBytes = BS.pack [0x4c, 0x5a, 0x49, 0x50] lzopMagicBytes :: BS.ByteString lzopMagicBytes = BS.pack [0x89, 0x4c, 0x5a, 0x4f, 0x00, 0x0d, 0x0a, 0x1a, 0x0a] snappyStreamIdentifier :: BS.ByteString snappyStreamIdentifier = BS.pack [0xff, 0x06, 0x00, 0x00, 0x73, 0x4e, 0x61, 0x50, 0x70, 0x59] gzipId :: BS.ByteString gzipId = BS.pack [0x1f, 0x8b] bzMagic :: BS.ByteString bzMagic = BS.pack [0x42, 0x5a] lz4Magic :: BS.ByteString lz4Magic = BS.pack [0x04, 0x22, 0x4d, 0x18] xzMagic :: BS.ByteString xzMagic = BS.pack [0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00]