@@ -31,19 +31,37 @@ module.exports = function () {
3131
3232 loadFromBinary : function ( /*Buffer*/ data ) {
3333 // data should be 22 bytes and start with "PK 05 06"
34- if ( data . length !== Constants . ENDHDR || data . readUInt32LE ( 0 ) !== Constants . ENDSIG )
34+ // or be 56+ bytes and start with "PK 06 06" for Zip64
35+ if ( ( data . length !== Constants . ENDHDR || data . readUInt32LE ( 0 ) !== Constants . ENDSIG ) &&
36+ ( data . length < Constants . ZIP64HDR || data . readUInt32LE ( 0 ) !== Constants . ZIP64SIG ) ) {
37+
3538 throw Utils . Errors . INVALID_END ;
39+ }
40+
41+ if ( data . readUInt32LE ( 0 ) === Constants . ENDSIG ) {
42+ // number of entries on this volume
43+ _volumeEntries = data . readUInt16LE ( Constants . ENDSUB ) ;
44+ // total number of entries
45+ _totalEntries = data . readUInt16LE ( Constants . ENDTOT ) ;
46+ // central directory size in bytes
47+ _size = data . readUInt32LE ( Constants . ENDSIZ ) ;
48+ // offset of first CEN header
49+ _offset = data . readUInt32LE ( Constants . ENDOFF ) ;
50+ // zip file comment length
51+ _commentLength = data . readUInt16LE ( Constants . ENDCOM ) ;
52+ } else {
53+ // number of entries on this volume
54+ _volumeEntries = Utils . readBigUInt64LE ( data , Constants . ZIP64SUB ) ;
55+ // total number of entries
56+ _totalEntries = Utils . readBigUInt64LE ( data , Constants . ZIP64TOT ) ;
57+ // central directory size in bytes
58+ _size = Utils . readBigUInt64LE ( data , Constants . ZIP64SIZ ) ;
59+ // offset of first CEN header
60+ _offset = Utils . readBigUInt64LE ( data , Constants . ZIP64OFF ) ;
61+
62+ _commentLength = 0 ;
63+ }
3664
37- // number of entries on this volume
38- _volumeEntries = data . readUInt16LE ( Constants . ENDSUB ) ;
39- // total number of entries
40- _totalEntries = data . readUInt16LE ( Constants . ENDTOT ) ;
41- // central directory size in bytes
42- _size = data . readUInt32LE ( Constants . ENDSIZ ) ;
43- // offset of first CEN header
44- _offset = data . readUInt32LE ( Constants . ENDOFF ) ;
45- // zip file comment length
46- _commentLength = data . readUInt16LE ( Constants . ENDCOM ) ;
4765 } ,
4866
4967 toBinary : function ( ) {
0 commit comments