node-stream-zip 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_stream_zip.js +9 -9
- package/package.json +1 -1
package/node_stream_zip.js
CHANGED
|
@@ -397,7 +397,7 @@ var StreamZip = function(config) {
|
|
|
397
397
|
if (err)
|
|
398
398
|
throw err;
|
|
399
399
|
var
|
|
400
|
-
data =
|
|
400
|
+
data = Buffer.alloc(entry.compressedSize),
|
|
401
401
|
bytesRead;
|
|
402
402
|
new FsRead(fd, data, 0, entry.compressedSize, dataOffset(entry), function(e, br) {
|
|
403
403
|
err = e;
|
|
@@ -431,7 +431,7 @@ var StreamZip = function(config) {
|
|
|
431
431
|
return callback('Entry is not file');
|
|
432
432
|
if (!fd)
|
|
433
433
|
return callback('Archive closed');
|
|
434
|
-
var buffer =
|
|
434
|
+
var buffer = Buffer.alloc(consts.LOCHDR);
|
|
435
435
|
new FsRead(fd, buffer, 0, buffer.length, entry.offset, function(err) {
|
|
436
436
|
if (err)
|
|
437
437
|
return callback(err);
|
|
@@ -867,7 +867,7 @@ FsRead.prototype.readCallback = function(sync, err, bytesRead) {
|
|
|
867
867
|
|
|
868
868
|
var FileWindowBuffer = function(fd) {
|
|
869
869
|
this.position = 0;
|
|
870
|
-
this.buffer =
|
|
870
|
+
this.buffer = Buffer.alloc(0);
|
|
871
871
|
|
|
872
872
|
var fsOp = null;
|
|
873
873
|
|
|
@@ -879,14 +879,14 @@ var FileWindowBuffer = function(fd) {
|
|
|
879
879
|
this.read = function(pos, length, callback) {
|
|
880
880
|
this.checkOp();
|
|
881
881
|
if (this.buffer.length < length)
|
|
882
|
-
this.buffer =
|
|
882
|
+
this.buffer = Buffer.alloc(length);
|
|
883
883
|
this.position = pos;
|
|
884
884
|
fsOp = new FsRead(fd, this.buffer, 0, length, this.position, callback).read();
|
|
885
885
|
};
|
|
886
886
|
|
|
887
887
|
this.expandLeft = function(length, callback) {
|
|
888
888
|
this.checkOp();
|
|
889
|
-
this.buffer = Buffer.concat([
|
|
889
|
+
this.buffer = Buffer.concat([Buffer.alloc(length), this.buffer]);
|
|
890
890
|
this.position -= length;
|
|
891
891
|
if (this.position < 0)
|
|
892
892
|
this.position = 0;
|
|
@@ -896,7 +896,7 @@ var FileWindowBuffer = function(fd) {
|
|
|
896
896
|
this.expandRight = function(length, callback) {
|
|
897
897
|
this.checkOp();
|
|
898
898
|
var offset = this.buffer.length;
|
|
899
|
-
this.buffer = Buffer.concat([this.buffer,
|
|
899
|
+
this.buffer = Buffer.concat([this.buffer, Buffer.alloc(length)]);
|
|
900
900
|
fsOp = new FsRead(fd, this.buffer, offset, length, this.position + offset, callback).read();
|
|
901
901
|
};
|
|
902
902
|
|
|
@@ -928,7 +928,7 @@ var EntryDataReaderStream = function(fd, offset, length) {
|
|
|
928
928
|
util.inherits(EntryDataReaderStream, stream.Readable);
|
|
929
929
|
|
|
930
930
|
EntryDataReaderStream.prototype._read = function(n) {
|
|
931
|
-
var buffer =
|
|
931
|
+
var buffer = Buffer.alloc(Math.min(n, this.length - this.pos));
|
|
932
932
|
if (buffer.length) {
|
|
933
933
|
fs.read(this.fd, buffer, 0, buffer.length, this.offset + this.pos, this.readCallback);
|
|
934
934
|
} else {
|
|
@@ -996,7 +996,7 @@ CrcVerify.prototype.data = function(data) {
|
|
|
996
996
|
this.state.crc = crc;
|
|
997
997
|
this.state.size += data.length;
|
|
998
998
|
if (this.state.size >= this.size) {
|
|
999
|
-
var buf =
|
|
999
|
+
var buf = Buffer.alloc(4);
|
|
1000
1000
|
buf.writeInt32LE(~this.state.crc & 0xffffffff, 0);
|
|
1001
1001
|
crc = buf.readUInt32LE(0);
|
|
1002
1002
|
if (crc !== this.crc)
|
|
@@ -1010,7 +1010,7 @@ CrcVerify.getCrcTable = function() {
|
|
|
1010
1010
|
var crcTable = CrcVerify.crcTable;
|
|
1011
1011
|
if (!crcTable) {
|
|
1012
1012
|
CrcVerify.crcTable = crcTable = [];
|
|
1013
|
-
var b =
|
|
1013
|
+
var b = Buffer.alloc(4);
|
|
1014
1014
|
for (var n = 0; n < 256; n++) {
|
|
1015
1015
|
var c = n;
|
|
1016
1016
|
for (var k = 8; --k >= 0; )
|