82 public static Archive
decode(ByteBuffer data)
throws IOException {
83 int length = ByteBufferUtil.getMedium(data);
84 int compressedLength = ByteBufferUtil.getMedium(data);
86 byte[] uncompressedData = data.array();
88 if (compressedLength != length) {
90 data = ByteBuffer.wrap(uncompressedData);
93 int total = data.getShort() & 0xFF;
94 int offset = data.position() + total * 10;
96 Int2ObjectMap<ArchiveSector> sectors =
new Int2ObjectOpenHashMap<>(total);
97 for (
int i = 0; i < total; i++) {
98 int hash = data.getInt();
99 length = ByteBufferUtil.getMedium(data);
100 compressedLength = ByteBufferUtil.getMedium(data);
102 byte[] sectorData =
new byte[length];
104 if (length != compressedLength) {
107 System.arraycopy(uncompressedData, offset, sectorData, 0, length);
110 sectors.put(hash,
new ArchiveSector(ByteBuffer.wrap(sectorData), hash));
111 offset += compressedLength;
114 return new Archive(sectors);