Function mrpt::io::detect_compression

Function Documentation

CompressionType mrpt::io::detect_compression(const std::string &filePath)

Detects whether a file is gzip- or Zstandard-compressed, or none.

This function inspects the magic bytes at the beginning of the file to identify well-known compression formats:

  • Gzip: magic bytes 0x1F 0x8B

  • Zstandard: magic bytes 0x28 0xB5 0x2F 0xFD

  • Zstandard skippable frames: 0x2A 0x4D 0x18 0x5x

The detection is constant-time and does not attempt full decompression.

Parameters:

filePath – Path to the file to inspect.

Returns:

The detected compression type, or CompressionType::None if the format is not recognized.