// Detect It Easy: detection rule file
// Author: horsicq <horsicq@gmail.com>

// Part of cdrkit project
meta("tool", "genisoimage");

function detect() {
    var sAppId = ISO9660.getApplicationIdentifier().toUpperCase();

    if (sAppId.indexOf("GENISOIMAGE") !== -1) {
        bDetected = true;

        // Try to extract version from copyright years
        // Format: "GENISOIMAGE ISO 9660/HFS FILESYSTEM CREATOR (C) 1993 E.YOUNGDALE (C) 1997-2006 J.PEARSON/J.SCHILLING (C) 2006-2007 CDRKIT TEAM"
        var nCdrkitPos = sAppId.indexOf("CDRKIT TEAM");
        if (nCdrkitPos !== -1) {
            // Look for the year range before "CDRKIT TEAM"
            var sPart = sAppId.substring(0, nCdrkitPos),
                nLastCPos = sPart.lastIndexOf("(C)");

            if (nLastCPos !== -1) {
                var sYearPart = sPart.substring(nLastCPos + 4).trim(),
                    nSpacePos = sYearPart.indexOf(" ");

                if (nSpacePos !== -1) {
                    sVersion = sYearPart.substring(0, nSpacePos).trim();
                }
            }
        }
    }

    return result();
}