// Detect It Easy: detection rule file
// Author: horsicq <horsicq@gmail.com>
// doc-ref: https://github.com/dsnet/compress/blob/master/doc/bzip2-format.pdf

meta("archive", "BZip");

function detect() {
    if (Binary.getSize() >= 9) {
        if (Binary.compare("'BZ0'")) {
            sVersion = "1.0";
            sOptions = "compressed data (.BZ)";
            bDetected = true;
        } else if (Binary.compare("'BZh'") && Binary.compare("314159265359", 0x4)) {
            sName = "BZip2 compressed data (.BZ2)"
            bDetected = true;
        }
        if (bDetected && Binary.isVerbose()) {
            sOptions = "block-size:" + Binary.getString(3, 1) + "00 kb";
        }
    }

    return result();
}