compress-commons
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -88,3 +88,2 @@ /** | ||
} else if (util.isStream(source)) { | ||
source.on('error', callback); | ||
this._appendStream(ae, source, callback); | ||
@@ -91,0 +90,0 @@ } else { |
@@ -8,8 +8,9 @@ /** | ||
*/ | ||
var Int64 = require('node-int64'); | ||
var util = module.exports = {}; | ||
util.dateToDos = function(d) { | ||
var year = d.getUTCFullYear(); | ||
util.dateToDos = function(d, forceLocalTime) { | ||
forceLocalTime = forceLocalTime || false; | ||
var year = forceLocalTime ? d.getFullYear() : d.getUTCFullYear(); | ||
if (year < 1980) { | ||
@@ -23,7 +24,7 @@ return 2162688; // 1980-1-1 00:00:00 | ||
year: year, | ||
month: d.getUTCMonth(), | ||
date: d.getUTCDate(), | ||
hours: d.getUTCHours(), | ||
minutes: d.getUTCMinutes(), | ||
seconds: d.getUTCSeconds() | ||
month: forceLocalTime ? d.getMonth() : d.getUTCMonth(), | ||
date: forceLocalTime ? d.getDate() : d.getUTCDate(), | ||
hours: forceLocalTime ? d.getHours() : d.getUTCHours(), | ||
minutes: forceLocalTime ? d.getMinutes() : d.getUTCMinutes(), | ||
seconds: forceLocalTime ? d.getSeconds() : d.getUTCSeconds() | ||
}; | ||
@@ -36,10 +37,3 @@ | ||
util.dosToDate = function(dos) { | ||
return new Date( | ||
((dos >> 25) & 0x7f) + 1980, | ||
((dos >> 21) & 0x0f) - 1, | ||
(dos >> 16) & 0x1f, | ||
(dos >> 11) & 0x1f, | ||
(dos >> 5) & 0x3f, | ||
(dos & 0x1f) << 1 | ||
); | ||
return new Date(((dos >> 25) & 0x7f) + 1980, ((dos >> 21) & 0x0f) - 1, (dos >> 16) & 0x1f, (dos >> 11) & 0x1f, (dos >> 5) & 0x3f, (dos & 0x1f) << 1); | ||
}; | ||
@@ -53,9 +47,5 @@ | ||
var buf = new Buffer(8); | ||
var i64 = new Int64(v); | ||
buf.writeUInt32LE(v % 0x0100000000, 0); | ||
buf.writeUInt32LE((v / 0x0100000000) | 0, 4); | ||
// BE to LE | ||
for(i = 0; i < 8; i++) { | ||
buf[i] = i64.buffer[7 - i]; | ||
} | ||
return buf; | ||
@@ -62,0 +52,0 @@ }; |
@@ -194,3 +194,3 @@ /** | ||
ZipArchiveEntry.prototype.setTime = function(time) { | ||
ZipArchiveEntry.prototype.setTime = function(time, forceLocalTime) { | ||
if (!(time instanceof Date)) { | ||
@@ -200,3 +200,3 @@ throw new Error('invalid entry time'); | ||
this.time = zipUtil.dateToDos(time); | ||
this.time = zipUtil.dateToDos(time, forceLocalTime); | ||
}; | ||
@@ -203,0 +203,0 @@ |
@@ -38,3 +38,5 @@ /** | ||
finished: false, | ||
processing: false | ||
processing: false, | ||
forceZip64: options.forceZip64, | ||
forceLocalTime: options.forceLocalTime | ||
}; | ||
@@ -96,2 +98,6 @@ }; | ||
var smart = this._smartStream(ae, callback); | ||
source.once('error', function(err) { | ||
smart.emit('error', err); | ||
smart.end(); | ||
}) | ||
source.pipe(smart); | ||
@@ -113,2 +119,5 @@ }; | ||
o.forceZip64 = !!o.forceZip64; | ||
o.forceLocalTime = !!o.forceLocalTime; | ||
return o; | ||
@@ -149,3 +158,3 @@ }; | ||
if (ae.getTime() === -1) { | ||
ae.setTime(new Date()); | ||
ae.setTime(new Date(), this._archive.forceLocalTime); | ||
} | ||
@@ -163,4 +172,5 @@ | ||
var process = deflate ? new DeflateCRC32Stream(this.options.zlib) : new CRC32Stream(); | ||
var error = null; | ||
function handleStuff(err) { | ||
function handleStuff() { | ||
ae.setCrc(process.digest()); | ||
@@ -170,7 +180,9 @@ ae.setSize(process.size()); | ||
this._afterAppend(ae); | ||
callback(null, ae); | ||
callback(error, ae); | ||
} | ||
process.once('error', callback); | ||
process.once('end', handleStuff.bind(this)); | ||
process.once('error', function(err) { | ||
error = err; | ||
}); | ||
@@ -428,3 +440,3 @@ process.pipe(this, { end: false }); | ||
ZipArchiveOutputStream.prototype.isZip64 = function() { | ||
return this._entries.length > constants.ZIP64_MAGIC_SHORT || this._archive.centralLength > constants.ZIP64_MAGIC || this._archive.centralOffset > constants.ZIP64_MAGIC; | ||
return this._archive.forceZip64 || this._entries.length > constants.ZIP64_MAGIC_SHORT || this._archive.centralLength > constants.ZIP64_MAGIC || this._archive.centralOffset > constants.ZIP64_MAGIC; | ||
}; | ||
@@ -431,0 +443,0 @@ |
{ | ||
"name": "compress-commons", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "a library that defines a common interface for working with archive formats within node", | ||
@@ -31,3 +31,2 @@ "homepage": "https://github.com/archiverjs/node-compress-commons", | ||
"crc32-stream": "^1.0.0", | ||
"node-int64": "^0.4.0", | ||
"normalize-path": "^2.0.0", | ||
@@ -34,0 +33,0 @@ "readable-stream": "^2.0.0" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33142
4
- Removednode-int64@^0.4.0
- Removednode-int64@0.4.0(transitive)