@ -675,7 +675,7 @@ function Unpack29(bstream) {
continue ;
continue ;
}
}
}
}
rarUpdateProgress ( )
rarUpdateProgress ( ) ;
}
}
function rarReadEndOfBlock ( bstream ) {
function rarReadEndOfBlock ( bstream ) {
@ -703,7 +703,7 @@ function rarReadVMCode(bstream) {
Length = bstream . readBits ( 16 ) ;
Length = bstream . readBits ( 16 ) ;
}
}
var vmCode = [ ] ;
var vmCode = [ ] ;
for ( var I = 0 ; I < Length ; I ++ ) {
for ( var I = 0 ; I < Length ; I ++ ) {
//do something here with cheking readbuf
//do something here with cheking readbuf
vmCode . push ( bstream . readBits ( 8 ) ) ;
vmCode . push ( bstream . readBits ( 8 ) ) ;
}
}
@ -724,8 +724,8 @@ function rarInsertLastMatch(length, distance) {
}
}
function rarInsertOldDist ( distance ) {
function rarInsertOldDist ( distance ) {
rOldDist . splice ( 3 , 1 ) ;
rOldDist . splice ( 3 , 1 ) ;
rOldDist . splice ( 0 , 0 , distance ) ;
rOldDist . splice ( 0 , 0 , distance ) ;
}
}
//this is the real function, the other one is for debugging
//this is the real function, the other one is for debugging
@ -737,16 +737,16 @@ function rarCopyString(length, distance) {
destPtr = rOldBuffers [ -- l ] . data . length + destPtr ;
destPtr = rOldBuffers [ -- l ] . data . length + destPtr ;
}
}
//TODO: lets hope that it never needs to read beyond file boundaries
//TODO: lets hope that it never needs to read beyond file boundaries
while ( length -- ) rBuffer . insertByte ( rOldBuffers [ l ] . data [ destPtr ++ ] ) ;
while ( length -- ) rBuffer . insertByte ( rOldBuffers [ l ] . data [ destPtr ++ ] ) ;
}
}
if ( length > distance ) {
if ( length > distance ) {
while ( length -- ) rBuffer . insertByte ( rBuffer . data [ destPtr ++ ] ) ;
while ( length -- ) rBuffer . insertByte ( rBuffer . data [ destPtr ++ ] ) ;
} else {
} else {
rBuffer . insertBytes ( rBuffer . data . subarray ( destPtr , destPtr + length ) ) ;
rBuffer . insertBytes ( rBuffer . data . subarray ( destPtr , destPtr + length ) ) ;
}
}
}
}
var rOldBuffers = [ ]
var rOldBuffers = [ ] ;
// v must be a valid RarVolume
// v must be a valid RarVolume
function unpack ( v ) {
function unpack ( v ) {
@ -757,7 +757,7 @@ function unpack(v) {
rBuffer = new bitjs . io . ByteBuffer ( v . header . unpackedSize ) ;
rBuffer = new bitjs . io . ByteBuffer ( v . header . unpackedSize ) ;
info ( "Unpacking " + v . filename + " RAR v" + Ver ) ;
info ( "Unpacking " + v . filename + " RAR v" + Ver ) ;
switch ( Ver ) {
switch ( Ver ) {
case 15 : // rar 1.5 compression
case 15 : // rar 1.5 compression
@ -818,7 +818,7 @@ RarLocalFile.prototype.unrar = function() {
this . fileData = unpack ( this ) ;
this . fileData = unpack ( this ) ;
}
}
}
}
}
} ;
var unrar = function ( arrayBuffer ) {
var unrar = function ( arrayBuffer ) {
currentFilename = "" ;
currentFilename = "" ;
@ -835,16 +835,16 @@ var unrar = function(arrayBuffer) {
if ( header . crc === 0x6152 &&
if ( header . crc === 0x6152 &&
header . headType === 0x72 &&
header . headType === 0x72 &&
header . flags . value === 0x1A21 &&
header . flags . value === 0x1A21 &&
header . headSize === 7 )
header . headSize === 7 ) {
{
info ( "Found RAR signature" ) ;
info ( "Found RAR signature" ) ;
var mhead = new RarVolumeHeader ( bstream ) ;
var mhead = new RarVolumeHeader ( bstream ) ;
if ( mhead . headType != MAIN _HEAD ) {
if ( mhead . headType != MAIN _HEAD ) {
info ( "Error! RAR did not include a MAIN_HEAD header" ) ;
info ( "Error! RAR did not include a MAIN_HEAD header" ) ;
} else {
} else {
var localFiles = [ ] ,
var localFiles = [ ] ;
localFile = null ;
var localFile = null ;
do {
do {
try {
try {
localFile = new RarLocalFile ( bstream ) ;
localFile = new RarLocalFile ( bstream ) ;
@ -855,22 +855,22 @@ var unrar = function(arrayBuffer) {
} else if ( localFile . header . packSize === 0 && localFile . header . unpackedSize === 0 ) {
} else if ( localFile . header . packSize === 0 && localFile . header . unpackedSize === 0 ) {
localFile . isValid = true ;
localFile . isValid = true ;
}
}
} catch ( err ) {
} catch ( err ) {
break ;
break ;
}
}
//info("bstream" + bstream.bytePtr+"/"+bstream.bytes.length);
//info("bstream" + bstream.bytePtr+"/"+bstream.bytes.length);
} while ( localFile . isValid ) ;
} while ( localFile . isValid ) ;
totalFilesInArchive = localFiles . length ;
totalFilesInArchive = localFiles . length ;
// now we have all information but things are unpacked
// now we have all information but things are unpacked
// TODO: unpack
// TODO: unpack
localFiles = localFiles . sort ( function ( a , b ) {
localFiles = localFiles . sort ( function ( a , b ) {
var aname = a . filename . toLowerCase ( ) ;
var aname = a . filename . toLowerCase ( ) ;
var bname = b . filename . toLowerCase ( ) ;
var bname = b . filename . toLowerCase ( ) ;
return aname > bname ? 1 : - 1 ;
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 ) {
for ( var i = 0 ; i < localFiles . length ; ++ i ) {
var localfile = localFiles [ i ] ;
var localfile = localFiles [ i ] ;