|
|
|
@ -41,10 +41,10 @@ var postProgress = function() {
|
|
|
|
|
// shows a byte value as its hex representation
|
|
|
|
|
var nibble = "0123456789ABCDEF";
|
|
|
|
|
var byteValueToHexString = function(num) {
|
|
|
|
|
return nibble[num>>4] + nibble[num&0xF];
|
|
|
|
|
return nibble[num >> 4] + nibble[num & 0xF];
|
|
|
|
|
};
|
|
|
|
|
var twoByteValueToHexString = function(num) {
|
|
|
|
|
return nibble[(num>>12)&0xF] + nibble[(num>>8)&0xF] + nibble[(num>>4)&0xF] + nibble[num&0xF];
|
|
|
|
|
return nibble[(num >> 12) & 0xF] + nibble[(num >> 8) & 0xF] + nibble[(num >> 4) & 0xF] + nibble[num & 0xF];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -69,7 +69,7 @@ var MARK_HEAD = 0x72,
|
|
|
|
|
var RarVolumeHeader = function(bstream) {
|
|
|
|
|
var headPos = bstream.bytePtr;
|
|
|
|
|
// byte 1,2
|
|
|
|
|
info("Rar Volume Header @"+bstream.bytePtr);
|
|
|
|
|
info("Rar Volume Header @" + bstream.bytePtr);
|
|
|
|
|
|
|
|
|
|
this.crc = bstream.readBits(16);
|
|
|
|
|
info(" crc=" + this.crc);
|
|
|
|
@ -180,13 +180,13 @@ var RarVolumeHeader = function(bstream) {
|
|
|
|
|
|
|
|
|
|
// this is adapted straight out of arcread.cpp, Archive::ReadHeader()
|
|
|
|
|
for (var I = 0; I < 4; ++I) {
|
|
|
|
|
var rmode = extTimeFlags >> ((3-I)*4);
|
|
|
|
|
if ((rmode & 8)==0) {
|
|
|
|
|
var rmode = extTimeFlags >> ((3 - I) * 4);
|
|
|
|
|
if ((rmode & 8) == 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (I!=0)
|
|
|
|
|
if (I != 0)
|
|
|
|
|
bstream.readBits(16);
|
|
|
|
|
var count = (rmode&3);
|
|
|
|
|
var count = (rmode & 3);
|
|
|
|
|
for (var J = 0; J < count; ++J) {
|
|
|
|
|
bstream.readBits(8);
|
|
|
|
|
}
|
|
|
|
@ -208,7 +208,7 @@ var RarVolumeHeader = function(bstream) {
|
|
|
|
|
default:
|
|
|
|
|
info("Found a header of type 0x" + byteValueToHexString(this.headType));
|
|
|
|
|
// skip the rest of the header bytes (for now)
|
|
|
|
|
bstream.readBytes( this.headSize - 7 );
|
|
|
|
|
bstream.readBytes(this.headSize - 7);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
@ -216,21 +216,23 @@ var RarVolumeHeader = function(bstream) {
|
|
|
|
|
var BLOCK_LZ = 0,
|
|
|
|
|
BLOCK_PPM = 1;
|
|
|
|
|
|
|
|
|
|
var rLDecode = [0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224],
|
|
|
|
|
rLBits = [0,0,0,0,0,0,0,0,1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],
|
|
|
|
|
rDBitLengthCounts = [4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,14,0,12],
|
|
|
|
|
rSDDecode = [0,4,8,16,32,64,128,192],
|
|
|
|
|
rSDBits = [2,2,3, 4, 5, 6, 6, 6];
|
|
|
|
|
var rLDecode = [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224],
|
|
|
|
|
rLBits = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],
|
|
|
|
|
rDBitLengthCounts = [4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 14, 0, 12],
|
|
|
|
|
rSDDecode = [0, 4, 8, 16, 32, 64, 128, 192],
|
|
|
|
|
rSDBits = [2, 2, 3, 4, 5, 6, 6, 6];
|
|
|
|
|
|
|
|
|
|
var rDDecode = [0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32,
|
|
|
|
|
48, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 3072,
|
|
|
|
|
4096, 6144, 8192, 12288, 16384, 24576, 32768, 49152, 65536, 98304,
|
|
|
|
|
131072, 196608, 262144, 327680, 393216, 458752, 524288, 589824,
|
|
|
|
|
655360, 720896, 786432, 851968, 917504, 983040];
|
|
|
|
|
655360, 720896, 786432, 851968, 917504, 983040
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
var rDBits = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5,
|
|
|
|
|
5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14,
|
|
|
|
|
15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16];
|
|
|
|
|
15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
var rLOW_DIST_REP_COUNT = 16;
|
|
|
|
|
|
|
|
|
@ -239,7 +241,7 @@ var rNC = 299,
|
|
|
|
|
rLDC = 17,
|
|
|
|
|
rRC = 28,
|
|
|
|
|
rBC = 20,
|
|
|
|
|
rHUFF_TABLE_SIZE = (rNC+rDC+rRC+rLDC);
|
|
|
|
|
rHUFF_TABLE_SIZE = (rNC + rDC + rRC + rLDC);
|
|
|
|
|
|
|
|
|
|
var UnpBlockType = BLOCK_LZ;
|
|
|
|
|
var UnpOldTable = new Array(rHUFF_TABLE_SIZE);
|
|
|
|
@ -308,7 +310,7 @@ function RarReadTables(bstream) {
|
|
|
|
|
var Table = new Array(rHUFF_TABLE_SIZE);
|
|
|
|
|
|
|
|
|
|
// before we start anything we need to get byte-aligned
|
|
|
|
|
bstream.readBits( (8 - bstream.bitPtr) & 0x7 );
|
|
|
|
|
bstream.readBits((8 - bstream.bitPtr) & 0x7);
|
|
|
|
|
|
|
|
|
|
if (bstream.readBits(1)) {
|
|
|
|
|
info("Error! PPM not implemented yet");
|
|
|
|
@ -328,15 +330,13 @@ function RarReadTables(bstream) {
|
|
|
|
|
var ZeroCount = bstream.readBits(4);
|
|
|
|
|
if (ZeroCount == 0) {
|
|
|
|
|
BitLength[I] = 15;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
ZeroCount += 2;
|
|
|
|
|
while (ZeroCount-- > 0 && I < rBC)
|
|
|
|
|
BitLength[I++] = 0;
|
|
|
|
|
--I;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
BitLength[I] = Length;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -381,26 +381,28 @@ function RarReadTables(bstream) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function RarDecodeNumber(bstream, dec) {
|
|
|
|
|
var DecodeLen = dec.DecodeLen, DecodePos = dec.DecodePos, DecodeNum = dec.DecodeNum;
|
|
|
|
|
var DecodeLen = dec.DecodeLen,
|
|
|
|
|
DecodePos = dec.DecodePos,
|
|
|
|
|
DecodeNum = dec.DecodeNum;
|
|
|
|
|
var bitField = bstream.getBits() & 0xfffe;
|
|
|
|
|
//some sort of rolled out binary search
|
|
|
|
|
var bits = ((bitField < DecodeLen[8])?
|
|
|
|
|
((bitField < DecodeLen[4])?
|
|
|
|
|
((bitField < DecodeLen[2])?
|
|
|
|
|
((bitField < DecodeLen[1])?1:2)
|
|
|
|
|
:((bitField < DecodeLen[3])?3:4))
|
|
|
|
|
:(bitField < DecodeLen[6])?
|
|
|
|
|
((bitField < DecodeLen[5])?5:6)
|
|
|
|
|
:((bitField < DecodeLen[7])?7:8))
|
|
|
|
|
:((bitField < DecodeLen[12])?
|
|
|
|
|
((bitField < DecodeLen[10])?
|
|
|
|
|
((bitField < DecodeLen[9])?9:10)
|
|
|
|
|
:((bitField < DecodeLen[11])?11:12))
|
|
|
|
|
:(bitField < DecodeLen[14])?
|
|
|
|
|
((bitField < DecodeLen[13])?13:14)
|
|
|
|
|
:15));
|
|
|
|
|
var bits = ((bitField < DecodeLen[8]) ?
|
|
|
|
|
((bitField < DecodeLen[4]) ?
|
|
|
|
|
((bitField < DecodeLen[2]) ?
|
|
|
|
|
((bitField < DecodeLen[1]) ? 1 : 2) :
|
|
|
|
|
((bitField < DecodeLen[3]) ? 3 : 4)) :
|
|
|
|
|
(bitField < DecodeLen[6]) ?
|
|
|
|
|
((bitField < DecodeLen[5]) ? 5 : 6) :
|
|
|
|
|
((bitField < DecodeLen[7]) ? 7 : 8)) :
|
|
|
|
|
((bitField < DecodeLen[12]) ?
|
|
|
|
|
((bitField < DecodeLen[10]) ?
|
|
|
|
|
((bitField < DecodeLen[9]) ? 9 : 10) :
|
|
|
|
|
((bitField < DecodeLen[11]) ? 11 : 12)) :
|
|
|
|
|
(bitField < DecodeLen[14]) ?
|
|
|
|
|
((bitField < DecodeLen[13]) ? 13 : 14) :
|
|
|
|
|
15));
|
|
|
|
|
bstream.readBits(bits);
|
|
|
|
|
var N = DecodePos[bits] + ((bitField - DecodeLen[bits -1]) >>> (16 - bits));
|
|
|
|
|
var N = DecodePos[bits] + ((bitField - DecodeLen[bits - 1]) >>> (16 - bits));
|
|
|
|
|
|
|
|
|
|
return DecodeNum[N];
|
|
|
|
|
}
|
|
|
|
@ -410,8 +412,8 @@ function RarMakeDecodeTables(BitLength, offset, dec, size) {
|
|
|
|
|
var DecodeLen = dec.DecodeLen;
|
|
|
|
|
var DecodePos = dec.DecodePos;
|
|
|
|
|
var DecodeNum = dec.DecodeNum;
|
|
|
|
|
var LenCount = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
|
|
|
|
|
var TmpPos = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
|
|
|
|
|
var LenCount = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
|
|
|
var TmpPos = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
|
|
|
var N = 0;
|
|
|
|
|
var M = 0;
|
|
|
|
|
|
|
|
|
@ -427,18 +429,18 @@ function RarMakeDecodeTables(BitLength, offset, dec, size) {
|
|
|
|
|
DecodeLen[0] = 0;
|
|
|
|
|
|
|
|
|
|
for (var I = 1; I < 16; ++I) {
|
|
|
|
|
N = 2 * (N+LenCount[I]);
|
|
|
|
|
M = (N << (15-I));
|
|
|
|
|
N = 2 * (N + LenCount[I]);
|
|
|
|
|
M = (N << (15 - I));
|
|
|
|
|
if (M > 0xFFFF) {
|
|
|
|
|
M = 0xFFFF;
|
|
|
|
|
}
|
|
|
|
|
DecodeLen[I] = M;
|
|
|
|
|
DecodePos[I] = DecodePos[I-1] + LenCount[I-1];
|
|
|
|
|
DecodePos[I] = DecodePos[I - 1] + LenCount[I - 1];
|
|
|
|
|
TmpPos[I] = DecodePos[I];
|
|
|
|
|
}
|
|
|
|
|
for (I = 0; I < size; ++I) {
|
|
|
|
|
if (BitLength[I + offset] != 0) {
|
|
|
|
|
DecodeNum[ TmpPos[ BitLength[offset + I] & 0xF ]++] = I;
|
|
|
|
|
DecodeNum[TmpPos[BitLength[offset + I] & 0xF]++] = I;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -503,7 +505,7 @@ function Unpack20(bstream, Solid) {
|
|
|
|
|
if (num < 261) {
|
|
|
|
|
var Distance = rOldDist[(oldDistPtr - (num - 256)) & 3];
|
|
|
|
|
var LengthNumber = RarDecodeNumber(bstream, RD);
|
|
|
|
|
var Length = rLDecode[LengthNumber] +2;
|
|
|
|
|
var Length = rLDecode[LengthNumber] + 2;
|
|
|
|
|
if ((Bits = rLBits[LengthNumber]) > 0) {
|
|
|
|
|
Length += bstream.readBits(Bits);
|
|
|
|
|
}
|
|
|
|
@ -600,7 +602,7 @@ function RarReadTables20(bstream) {
|
|
|
|
|
var lowDistRepCount = 0;
|
|
|
|
|
var prevLowDist = 0;
|
|
|
|
|
|
|
|
|
|
var rOldDist = [0,0,0,0];
|
|
|
|
|
var rOldDist = [0, 0, 0, 0];
|
|
|
|
|
var lastDist;
|
|
|
|
|
var lastLength;
|
|
|
|
|
|
|
|
|
@ -644,7 +646,7 @@ function InitFilters() {
|
|
|
|
|
*/
|
|
|
|
|
function RarAddVMCode(firstByte, vmCode) {
|
|
|
|
|
VM.init();
|
|
|
|
|
var bstream = new bitjs.io.BitStream(vmCode.buffer, true /* rtl */);
|
|
|
|
|
var bstream = new bitjs.io.BitStream(vmCode.buffer, true /* rtl */ );
|
|
|
|
|
|
|
|
|
|
var filtPos;
|
|
|
|
|
if (firstByte & 0x80) {
|
|
|
|
@ -716,9 +718,9 @@ function RarAddVMCode(firstByte, vmCode) {
|
|
|
|
|
if (firstByte & 0x20) {
|
|
|
|
|
stackFilter.BlockLength = RarVM.readData(bstream);
|
|
|
|
|
} else {
|
|
|
|
|
stackFilter.BlockLength = filtPos < OldFilterLengths.length
|
|
|
|
|
? OldFilterLengths[filtPos]
|
|
|
|
|
: 0;
|
|
|
|
|
stackFilter.BlockLength = filtPos < OldFilterLengths.length ?
|
|
|
|
|
OldFilterLengths[filtPos] :
|
|
|
|
|
0;
|
|
|
|
|
}
|
|
|
|
|
stackFilter.NextWindow = (wBuffer.ptr != rBuffer.ptr) &&
|
|
|
|
|
(((wBuffer.ptr - rBuffer.ptr) & MAXWINMASK) <= blockStart);
|
|
|
|
@ -788,7 +790,7 @@ function RarAddVMCode(firstByte, vmCode) {
|
|
|
|
|
// return(false);
|
|
|
|
|
var dataSize = RarVM.readData(bstream);
|
|
|
|
|
if (dataSize > (VM_GLOBALMEMSIZE - VM_FIXEDGLOBALSIZE)) {
|
|
|
|
|
return(false);
|
|
|
|
|
return (false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var curSize = stackFilter.Prg.GlobalData.length;
|
|
|
|
@ -849,17 +851,17 @@ function Unpack29(bstream, Solid) {
|
|
|
|
|
var BitLength = 0;
|
|
|
|
|
var Slot = 0;
|
|
|
|
|
|
|
|
|
|
for (var I = 0; I < rDBitLengthCounts.length; I++,BitLength++) {
|
|
|
|
|
for (var J = 0; J < rDBitLengthCounts[I]; J++,Slot++,Dist+=(1<<BitLength)) {
|
|
|
|
|
DDecode[Slot]=Dist;
|
|
|
|
|
DBits[Slot]=BitLength;
|
|
|
|
|
for (var I = 0; I < rDBitLengthCounts.length; I++, BitLength++) {
|
|
|
|
|
for (var J = 0; J < rDBitLengthCounts[I]; J++, Slot++, Dist += (1 << BitLength)) {
|
|
|
|
|
DDecode[Slot] = Dist;
|
|
|
|
|
DBits[Slot] = BitLength;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var Bits;
|
|
|
|
|
//tablesRead = false;
|
|
|
|
|
|
|
|
|
|
rOldDist = [0,0,0,0]
|
|
|
|
|
rOldDist = [0, 0, 0, 0]
|
|
|
|
|
|
|
|
|
|
lastDist = 0;
|
|
|
|
|
lastLength = 0;
|
|
|
|
@ -943,7 +945,7 @@ function Unpack29(bstream, Solid) {
|
|
|
|
|
var Distance = rOldDist[DistNum];
|
|
|
|
|
|
|
|
|
|
for (var I = DistNum; I > 0; I--) {
|
|
|
|
|
rOldDist[I] = rOldDist[I-1];
|
|
|
|
|
rOldDist[I] = rOldDist[I - 1];
|
|
|
|
|
}
|
|
|
|
|
rOldDist[0] = Distance;
|
|
|
|
|
|
|
|
|
@ -1109,8 +1111,8 @@ function RarWriteBuf() {
|
|
|
|
|
function RarWriteArea(startPtr, endPtr) {
|
|
|
|
|
if (endPtr < startPtr) {
|
|
|
|
|
console.error('endPtr < startPtr, endPtr=' + endPtr + ', startPtr=' + startPtr);
|
|
|
|
|
// RarWriteData(startPtr, -(int)StartPtr & MAXWINMASK);
|
|
|
|
|
// RarWriteData(0, endPtr);
|
|
|
|
|
// RarWriteData(startPtr, -(int)StartPtr & MAXWINMASK);
|
|
|
|
|
// RarWriteData(0, endPtr);
|
|
|
|
|
return;
|
|
|
|
|
} else if (startPtr < endPtr) {
|
|
|
|
|
RarWriteData(startPtr, endPtr - startPtr);
|
|
|
|
@ -1138,8 +1140,7 @@ function RarWriteData(offset, numBytes) {
|
|
|
|
|
/**
|
|
|
|
|
* @param {VM_PreparedProgram} prg
|
|
|
|
|
*/
|
|
|
|
|
function RarExecuteCode(prg)
|
|
|
|
|
{
|
|
|
|
|
function RarExecuteCode(prg) {
|
|
|
|
|
if (prg.GlobalData.length > 0) {
|
|
|
|
|
var writtenFileSize = wBuffer.ptr;
|
|
|
|
|
prg.InitR[6] = writtenFileSize;
|
|
|
|
@ -1152,7 +1153,8 @@ function RarExecuteCode(prg)
|
|
|
|
|
function RarReadEndOfBlock(bstream) {
|
|
|
|
|
RarUpdateProgress();
|
|
|
|
|
|
|
|
|
|
var NewTable = false, NewFile = false;
|
|
|
|
|
var NewTable = false,
|
|
|
|
|
NewFile = false;
|
|
|
|
|
if (bstream.readBits(1)) {
|
|
|
|
|
NewTable = true;
|
|
|
|
|
} else {
|
|
|
|
@ -1169,8 +1171,8 @@ function RarInsertLastMatch(length, distance) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function RarInsertOldDist(distance) {
|
|
|
|
|
rOldDist.splice(3,1);
|
|
|
|
|
rOldDist.splice(0,0,distance);
|
|
|
|
|
rOldDist.splice(3, 1);
|
|
|
|
|
rOldDist.splice(0, 0, distance);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -1208,7 +1210,7 @@ function unpack(v) {
|
|
|
|
|
// TODO: implement what happens when unpVer is < 15
|
|
|
|
|
var Ver = v.header.unpVer <= 15 ? 15 : v.header.unpVer;
|
|
|
|
|
var Solid = v.header.LHD_SOLID;
|
|
|
|
|
var bstream = new bitjs.io.BitStream(v.fileData.buffer, true /* rtl */, v.fileData.byteOffset, v.fileData.byteLength );
|
|
|
|
|
var bstream = new bitjs.io.BitStream(v.fileData.buffer, true /* rtl */ , v.fileData.byteOffset, v.fileData.byteLength);
|
|
|
|
|
|
|
|
|
|
rBuffer = new bitjs.io.ByteBuffer(v.header.unpackedSize);
|
|
|
|
|
|
|
|
|
@ -1242,8 +1244,7 @@ var RarLocalFile = function(bstream) {
|
|
|
|
|
if (this.header.headType != FILE_HEAD && this.header.headType != ENDARC_HEAD) {
|
|
|
|
|
this.isValid = false;
|
|
|
|
|
info("Error! RAR Volume did not include a FILE_HEAD header ");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
// read in the compressed data
|
|
|
|
|
this.fileData = null;
|
|
|
|
|
if (this.header.packSize > 0) {
|
|
|
|
@ -1257,7 +1258,7 @@ RarLocalFile.prototype.unrar = function() {
|
|
|
|
|
if (!this.header.flags.LHD_SPLIT_BEFORE) {
|
|
|
|
|
// unstore file
|
|
|
|
|
if (this.header.method == 0x30) {
|
|
|
|
|
info("Unstore "+this.filename);
|
|
|
|
|
info("Unstore " + this.filename);
|
|
|
|
|
this.isValid = true;
|
|
|
|
|
|
|
|
|
|
currentBytesUnarchivedInFile += this.fileData.length;
|
|
|
|
@ -1284,7 +1285,7 @@ var unrar = function(arrayBuffer) {
|
|
|
|
|
totalFilesInArchive = 0;
|
|
|
|
|
|
|
|
|
|
postMessage(new bitjs.archive.UnarchiveStartEvent());
|
|
|
|
|
var bstream = new bitjs.io.BitStream(arrayBuffer, false /* rtl */);
|
|
|
|
|
var bstream = new bitjs.io.BitStream(arrayBuffer, false /* rtl */ );
|
|
|
|
|
|
|
|
|
|
var header = new RarVolumeHeader(bstream);
|
|
|
|
|
if (header.crc == 0x6152 &&
|
|
|
|
@ -1296,8 +1297,7 @@ var unrar = function(arrayBuffer) {
|
|
|
|
|
var mhead = new RarVolumeHeader(bstream);
|
|
|
|
|
if (mhead.headType != MAIN_HEAD) {
|
|
|
|
|
info("Error! RAR did not include a MAIN_HEAD header");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
var localFiles = [],
|
|
|
|
|
localFile = null;
|
|
|
|
|
do {
|
|
|
|
@ -1310,7 +1310,7 @@ var unrar = function(arrayBuffer) {
|
|
|
|
|
} else if (localFile.header.packSize == 0 && localFile.header.unpackedSize == 0) {
|
|
|
|
|
localFile.isValid = true;
|
|
|
|
|
}
|
|
|
|
|
} catch(err) {
|
|
|
|
|
} catch (err) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
//info("bstream" + bstream.bytePtr+"/"+bstream.bytes.length);
|
|
|
|
@ -1319,13 +1319,15 @@ var unrar = function(arrayBuffer) {
|
|
|
|
|
|
|
|
|
|
// now we have all information but things are unpacked
|
|
|
|
|
// TODO: unpack
|
|
|
|
|
localFiles = localFiles.sort(function(a,b) {
|
|
|
|
|
localFiles = localFiles.sort(function(a, b) {
|
|
|
|
|
var aname = a.filename.toLowerCase();
|
|
|
|
|
var bname = b.filename.toLowerCase();
|
|
|
|
|
return aname > bname ? 1 : -1;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
info(localFiles.map(function(a){return a.filename}).join(', '));
|
|
|
|
|
info(localFiles.map(function(a) {
|
|
|
|
|
return a.filename
|
|
|
|
|
}).join(', '));
|
|
|
|
|
for (var i = 0; i < localFiles.length; ++i) {
|
|
|
|
|
var localfile = localFiles[i];
|
|
|
|
|
|
|
|
|
@ -1344,8 +1346,7 @@ var unrar = function(arrayBuffer) {
|
|
|
|
|
|
|
|
|
|
postProgress();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
err("Invalid RAR file");
|
|
|
|
|
}
|
|
|
|
|
postMessage(new bitjs.archive.UnarchiveFinishEvent());
|
|
|
|
|