Detect archive format from header bytes.
Examines magic bytes and known signatures at fixed offsets to identify the archive format. Falls back to registered provider detect functions if built-in detection does not match.
Parameters
headerBytes | First N bytes of the archive. Typically 8-263 bytes are sufficient; TAR requires at least 263 bytes for ustar detection at offset 257. |
Returns
The detected ArchiveFormat, or AUTO_DETECT if the format could not
be determined from the provided bytes.
Supported detections:
- ZIP: 4-byte magic (PK\\x03\\x04)
- 7-Zip: 6-byte magic (7z\\xBC\\xAF\\x27\\x1C)
- RAR4: 7-byte magic (Rar!\\x1A\\x07\\x00)
- RAR5: 7-byte magic (Rar!\\x1A\\x07\\x01\\x00)
- AR: 8-byte magic (!<arch>\\n)
- CAB: 4-byte magic (MSCF)
- XAR: 4-byte magic (xar!\\x00)
- CPIO: 6-byte magic ("070701", "070702", "070707")
- TAR: "ustar" at offset 257
- ISO9660: "CD001" at offset 32769