// Detect It Easy: detection rule file
// Author: LinXP
// doc-ref: https://www.opendesign.com/files/guestdownloads/OpenDesign_Specification_for_.dwg_files.pdf
// https://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-235B22E0-A567-4CF6-92D3-38A2306D73F3

meta("archive", "AutoCAD Drawing (.DWG)");

function detect() {
    if (Binary.getSize() >= 9) {
        bDetected = true;

        switch (Binary.getString(0, 0x06)) {
            case 'AC1001': sVersion = "R2.22"; break;
            case 'AC1002': sVersion = "R2.50"; break;
            case 'AC1003': sVersion = "R2.60"; break;
            case 'AC1004': sVersion = "R9"; break;
            case 'AC1006': sVersion = "R10"; break;
            case 'AC1009': sVersion = "R11/12"; break;
            case 'AC1012': sVersion = "R13"; break;
            case 'AC1014': sVersion = "R14"; break;
            case 'AC1015': sVersion = "R2000"; break;
            case 'AC1018': sVersion = "R2004"; break;
            case 'AC1021': sVersion = "R2007"; break;
            case 'AC1024': sVersion = "R2010"; break;
            case 'AC1027': sVersion = "R2013"; break;
            case 'AC1032': sVersion = "R2018"; break;
            default: return;
        }
    }

    return result();
}