1 | import {assert} from './util/assert';
|
2 |
|
3 | import {Packet} from './coders/byte-packets';
|
4 | import {FixedAsciiString, Uint8, Uint32BE} from './coders/byte-primitives';
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | class SB1Signature extends Packet.extend({
|
10 | |
11 |
|
12 |
|
13 |
|
14 |
|
15 | version: new FixedAsciiString(10),
|
16 |
|
17 | |
18 |
|
19 |
|
20 |
|
21 |
|
22 | infoByteLength: Uint32BE
|
23 | }) {
|
24 | |
25 |
|
26 |
|
27 |
|
28 |
|
29 | validate () {
|
30 | assert.validate(
|
31 | this.equals({version: 'ScratchV01'}) ||
|
32 | this.equals({version: 'ScratchV02'}),
|
33 | 'Invalid Scratch file signature.'
|
34 | );
|
35 | }
|
36 | }
|
37 |
|
38 | Packet.initConstructor(SB1Signature);
|
39 |
|
40 | class SB1Header extends Packet.extend({
|
41 | ObjS: new FixedAsciiString(4),
|
42 | ObjSValue: Uint8,
|
43 | Stch: new FixedAsciiString(4),
|
44 | StchValue: Uint8,
|
45 | numObjects: Uint32BE
|
46 | }) {
|
47 | validate () {
|
48 | assert.validate(
|
49 | this.equals({
|
50 | ObjS: 'ObjS',
|
51 | ObjSValue: 1,
|
52 | Stch: 'Stch',
|
53 | StchValue: 1
|
54 | }),
|
55 | 'Invalid Scratch file info packet header.'
|
56 | );
|
57 | }
|
58 | }
|
59 |
|
60 | Packet.initConstructor(SB1Header);
|
61 |
|
62 | export {SB1Signature, SB1Header};
|