File size: 2,175 Bytes
e4a10af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const smart_buffer_1 = require("smart-buffer");
const Language_1 = require("./Language");
function makeLicensePlist(licenses, context) {
    const ret = {
        "LPic": [],
        "RTF ": [],
        "STR#": [],
        "TEXT": []
    };
    // Assemble resources.
    for (const [index, item] of licenses.inOrder.entries()) {
        const ID = String(index + 5000);
        const Name = Language_1.default.byID[item.languageIDs[0]].englishName;
        ret["STR#"].push({
            Attributes: "0x0000",
            Data: item.labels,
            ID,
            Name
        });
        ret[item.body.type].push({
            Attributes: "0x0000",
            Data: item.body.data,
            ID,
            Name: `${Name} SLA`
        });
    }
    // Remove empty keys.
    for (const prop of ["RTF ", "TEXT"])
        if (!ret[prop].length)
            delete ret[prop];
    // Generate LPic.
    {
        const buf = smart_buffer_1.SmartBuffer.fromSize(4 + (6 * licenses.inOrder.length));
        // LPic header
        // The first field is the default language ID.
        buf.writeInt16BE(licenses.defaultLanguageID);
        // The second field is the count of language ID to license resource mappings.
        buf.writeUInt16BE(licenses.byLanguageID.size);
        // Next is the list of resource ID mappings.
        for (const [languageID, item] of licenses.byLanguageID.entries()) {
            // Mapping field 1: system language ID
            buf.writeInt16BE(languageID);
            // Mapping field 2: local resource ID minus 5000
            buf.writeInt16BE(licenses.inOrder.indexOf(item));
            // Mapping field 3: 2-byte language?
            // TODO: Figure out how modern macOS interprets this flag.
            buf.writeInt16BE(Language_1.default.byID[languageID].doubleByteCharset ? 1 : 0);
        }
        ret.LPic.push({
            Attributes: "0x0000",
            Data: buf.toBuffer(),
            ID: "5000",
            Name: ""
        });
    }
    return ret;
}
exports.default = makeLicensePlist;
//# sourceMappingURL=makeLicensePlist.js.map