|
14 | 14 | import { BitStream } from '../io/bitstream.js'; |
15 | 15 | import { ByteStream } from '../io/bytestream.js'; |
16 | 16 | import { ByteBuffer } from '../io/bytebuffer.js'; |
17 | | -import { RarVM, UnpackFilter, VM_GLOBALMEMADDR, VM_GLOBALMEMSIZE, VM_FIXEDGLOBALSIZE, MAXWINMASK } from './rarvm.js'; |
| 17 | +import { RarVM, UnpackFilter, VM_GLOBALMEMADDR, VM_GLOBALMEMSIZE, |
| 18 | + VM_FIXEDGLOBALSIZE, MAXWINMASK } from './rarvm.js'; |
18 | 19 |
|
19 | 20 | const UnarchiveState = { |
20 | 21 | NOT_STARTED: 0, |
@@ -509,6 +510,7 @@ function Unpack15(bstream, Solid) { |
509 | 510 | function Unpack20(bstream, Solid) { |
510 | 511 | const destUnpSize = rBuffer.data.length; |
511 | 512 | let oldDistPtr = 0; |
| 513 | + let Bits; |
512 | 514 |
|
513 | 515 | if (!Solid) { |
514 | 516 | RarReadTables20(bstream); |
@@ -1343,19 +1345,20 @@ class RarLocalFile { |
1343 | 1345 | function unrar_start() { |
1344 | 1346 | let bstream = bytestream.tee(); |
1345 | 1347 | const header = new RarVolumeHeader(bstream); |
1346 | | - if (header.crc == 0x6152 && |
1347 | | - header.headType == 0x72 && |
1348 | | - header.flags.value == 0x1A21 && |
1349 | | - header.headSize == 7) { |
1350 | | - if (logToConsole) { |
1351 | | - info('Found RAR signature'); |
1352 | | - } |
| 1348 | + if (header.crc == 0x6152 && header.headType == 0x72 && header.flags.value == 0x1A21) { |
| 1349 | + if (header.headSize == 7) { |
| 1350 | + if (logToConsole) { |
| 1351 | + info('Found RAR signature'); |
| 1352 | + } |
1353 | 1353 |
|
1354 | | - const mhead = new RarVolumeHeader(bstream); |
1355 | | - if (mhead.headType != MAIN_HEAD) { |
1356 | | - info('Error! RAR did not include a MAIN_HEAD header'); |
1357 | | - } else { |
1358 | | - bytestream = bstream.tee(); |
| 1354 | + const mhead = new RarVolumeHeader(bstream); |
| 1355 | + if (mhead.headType != MAIN_HEAD) { |
| 1356 | + info('Error! RAR did not include a MAIN_HEAD header'); |
| 1357 | + } else { |
| 1358 | + bytestream = bstream.tee(); |
| 1359 | + } |
| 1360 | + } else if (header.headSize === 0x107) { |
| 1361 | + throw 'Error! RAR5 files not supported yet. See https://github.com/codedread/bitjs/issues/25'; |
1359 | 1362 | } |
1360 | 1363 | } |
1361 | 1364 | } |
|
0 commit comments