| 6 | static constexpr uint32_t APPLESINGLE_VERSION = 0x00020000; |
| 7 | |
| 8 | void 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 | |
| 48 | Bytes AppleSingle::render() |
| 49 | { |
no test coverage detected