| 69 | } |
| 70 | |
| 71 | PackedAssetSource::PackedAssetSource(String const& filename) { |
| 72 | m_packedFile = File::open(filename, IOMode::Read); |
| 73 | |
| 74 | DataStreamIODevice ds(m_packedFile); |
| 75 | if (ds.readBytes(8) != ByteArray("SBAsset6", 8)) |
| 76 | throw AssetSourceException("Packed assets file format unrecognized!"); |
| 77 | |
| 78 | uint64_t indexStart = ds.read<uint64_t>(); |
| 79 | |
| 80 | ds.seek(indexStart); |
| 81 | ByteArray header = ds.readBytes(5); |
| 82 | if (header != ByteArray("INDEX", 5)) |
| 83 | throw AssetSourceException("No index header found!"); |
| 84 | ds.read(m_metadata); |
| 85 | ds.read(m_index); |
| 86 | } |
| 87 | |
| 88 | JsonObject PackedAssetSource::metadata() const { |
| 89 | return m_metadata; |