MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / parse

Method parse

lib/vfs/applesingle.cc:8–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6static constexpr uint32_t APPLESINGLE_VERSION = 0x00020000;
7
8void AppleSingle::parse(const Bytes& bytes)
9{
10 ByteReader br(bytes);
11 if (br.read_be32() != APPLESINGLE_MAGIC)
12 throw InvalidFileException();
13 if (br.read_be32() > APPLESINGLE_VERSION)
14 throw InvalidFileException();
15
16 br.skip(16);
17 int entries = br.read_be16();
18 for (int i = 0; i < entries; i++)
19 {
20 uint32_t entryType = br.read_be32();
21 uint32_t offset = br.read_be32();
22 uint32_t length = br.read_be32();
23
24 switch (entryType)
25 {
26 case 1:
27 data = bytes.slice(offset, length);
28 break;
29
30 case 2:
31 rsrc = bytes.slice(offset, length);
32 break;
33
34 case 9:
35 {
36 Bytes finderinfo = bytes.slice(offset, length);
37 type = finderinfo.slice(0, 4);
38 creator = finderinfo.slice(4, 4);
39 break;
40 }
41
42 default:
43 break;
44 }
45 }
46}
47
48Bytes AppleSingle::render()
49{

Callers 1

putFileMethod · 0.45

Calls 4

read_be32Method · 0.80
read_be16Method · 0.80
sliceMethod · 0.80

Tested by

no test coverage detected