MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / ReadVMCode

Method ReadVMCode

Libraries/unrar/unpack30.cpp:288–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286
287
288bool Unpack::ReadVMCode()
289{
290 // Entire VM code is guaranteed to fully present in block defined
291 // by current Huffman table. Compressor checks that VM code does not cross
292 // Huffman block boundaries.
293 uint FirstByte=Inp.getbits()>>8;
294 Inp.addbits(8);
295 uint Length=(FirstByte & 7)+1;
296 if (Length==7)
297 {
298 Length=(Inp.getbits()>>8)+7;
299 Inp.addbits(8);
300 }
301 else
302 if (Length==8)
303 {
304 Length=Inp.getbits();
305 Inp.addbits(16);
306 }
307 if (Length==0)
308 return false;
309 Array<byte> VMCode(Length);
310 for (uint I=0;I<Length;I++)
311 {
312 // Try to read the new buffer if only one byte is left.
313 // But if we read all bytes except the last, one byte is enough.
314 if (Inp.InAddr>=ReadTop-1 && !UnpReadBuf30() && I<Length-1)
315 return false;
316 VMCode[I]=Inp.getbits()>>8;
317 Inp.addbits(8);
318 }
319 return AddVMCode(FirstByte,&VMCode[0],Length);
320}
321
322
323bool Unpack::ReadVMCodePPM()

Callers

nothing calls this directly

Calls 2

getbitsMethod · 0.80
addbitsMethod · 0.80

Tested by

no test coverage detected