Comparing version 0.1.3 to 0.1.4
var fs = require("fs"), | ||
pth = require('path'); | ||
buffer = require("buffer"), | ||
pth = require("path"); | ||
@@ -19,2 +20,4 @@ var ZipEntry = require("./zipEntry"), | ||
} | ||
} else if(inPath && Buffer.isBuffer(inPath)) { // load buffer | ||
_zip = new ZipFile(inPath); | ||
} else { // create new zip file | ||
@@ -66,3 +69,3 @@ _zip = new ZipFile(); | ||
if (item) { | ||
item.getData(callback); | ||
item.getDataAsync(callback); | ||
} else { | ||
@@ -100,5 +103,7 @@ callback(null) | ||
if (item) { | ||
item.getData(function(data) { | ||
item.getDataAsync(function(data) { | ||
if (data && data.length) { | ||
callback(data.toString(encoding || "utf8")); | ||
} else { | ||
callback(""); | ||
} | ||
@@ -116,3 +121,3 @@ }) | ||
*/ | ||
deleteFile : function(/*Object*/entry) { | ||
deleteFile : function(/*Object*/entry) { // @TODO: test deleteFile | ||
var item = getEntry(entry); | ||
@@ -129,3 +134,3 @@ if (item) { | ||
*/ | ||
addZipComment : function(/*String*/comment) { | ||
addZipComment : function(/*String*/comment) { // @TODO: test addZipComment | ||
_zip.comment = comment; | ||
@@ -355,3 +360,11 @@ }, | ||
*/ | ||
writeZip : function(/*String*/targetFileName) { | ||
writeZip : function(/*String*/targetFileName, /*Function*/callback) { | ||
if (arguments.length == 1) { | ||
if (typeof targetFileName == "function") { | ||
callback = targetFileName; | ||
targetFileName = ""; | ||
} | ||
} | ||
if (!targetFileName && _filename) { | ||
@@ -361,2 +374,3 @@ targetFileName = _filename; | ||
if (!targetFileName) return; | ||
var zipData = _zip.toBuffer(); | ||
@@ -373,6 +387,17 @@ if (zipData) { | ||
*/ | ||
toBuffer : function() { | ||
toBuffer : function(/*Function*/callback) { | ||
this.valueOf = 2; | ||
if (typeof callback == "function") { | ||
_zip.toAsyncBuffer(callback); | ||
return null; | ||
} | ||
return _zip.toBuffer() | ||
} | ||
/*get lastError () { | ||
var x = function() { console.log("2", arguments); }; | ||
x.prototype = 2 | ||
return x; // | ||
} */ | ||
} | ||
}; |
@@ -1004,3 +1004,3 @@ function JSDeflater(/*inbuff*/inbuf) { | ||
var buff = new Array(1), | ||
var buff = new Array(1024), | ||
pages = [], | ||
@@ -1010,4 +1010,6 @@ totalSize = 0, | ||
for (i = 0; i < 1024; i++) buff[i] = 0; | ||
while((i = internalDeflate(buff, 0, buff.length)) > 0) { | ||
var buf = new Buffer(buff); | ||
var buf = new Buffer(buff.slice(0, i)); | ||
pages.push(buf); | ||
@@ -1018,2 +1020,3 @@ totalSize += buff.length; | ||
index = 0; | ||
for (i = 0; i < pages.length; i++) { | ||
@@ -1024,4 +1027,2 @@ pages[i].copy(result, index); | ||
cleanup(); | ||
return result; | ||
@@ -1032,3 +1033,3 @@ } | ||
deflate : function() { | ||
return deflate(inbuf, 9); | ||
return deflate(inbuf, 8); | ||
} | ||
@@ -1035,0 +1036,0 @@ } |
{ | ||
"name": "adm-zip", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "A Javascript implementation of zip for nodejs. Allows user to create or extract zip files both in memory or to/from disk", | ||
@@ -29,4 +29,4 @@ "keywords": [ | ||
"engines": { | ||
"node": ">=0.3.0" | ||
"node": ">=0.3.1" | ||
} | ||
} |
module.exports = require("./utils"); | ||
module.exports.Constants = require("./constants"); | ||
module.exports.Errors = require("./errors"); | ||
module.exports.FileAttr = require("./fattr"); |
@@ -6,11 +6,14 @@ var fs = require("fs"), | ||
var crcTable = []; // cache crc table | ||
var Constants = require('./constants'), | ||
Errors = require('./errors'); | ||
var crcTable = [], | ||
Constants = require('./constants'), | ||
Errors = require('./errors'), | ||
PATH_SEPARATOR = pth.normalize("/"); | ||
function mkdirSync(/*String*/path) { | ||
var resolvedPath = path.split('\\')[0]; | ||
path.split('\\').forEach(function(name) { | ||
var resolvedPath = path.split(PATH_SEPARATOR)[0]; | ||
path.split(PATH_SEPARATOR).forEach(function(name) { | ||
if (!name || name.substr(-1,1) == ":") return; | ||
resolvedPath += '\\' + name; | ||
resolvedPath += PATH_SEPARATOR + name; | ||
var stat; | ||
@@ -40,3 +43,3 @@ try { | ||
if (!pattern || pattern.test(path)) { | ||
files.push(path.replace(/\\/g, "/") + (fs.statSync(path).isDirectory() ? "/" : "")); | ||
files.push(pth.normalize(path) + (fs.statSync(path).isDirectory() ? PATH_SEPARATOR : "")); | ||
} | ||
@@ -120,2 +123,10 @@ | ||
getAttributes : function(/*String*/path) { | ||
}, | ||
setAttributes : function(/*String*/path) { | ||
}, | ||
Constants : Constants, | ||
@@ -122,0 +133,0 @@ Errors : Errors |
@@ -45,3 +45,3 @@ var Utils = require("./util"), | ||
if (Utils.crc32(_data) != _dataHeader.crc) { | ||
throw Utils.Errors.BAD_CRC + " " + _entryName | ||
console.warn( Utils.Errors.BAD_CRC + " " + _entryName) | ||
} | ||
@@ -77,2 +77,4 @@ } else { | ||
_data = new Buffer(0); | ||
_compressedData = new Buffer(0); | ||
return; | ||
} | ||
@@ -103,2 +105,4 @@ // Local file header | ||
_compressedData = new Buffer(deflated.length + Utils.Constants.LOCHDR + _entryName.length); | ||
_compressedData.fill(0); | ||
_dataHeader.toBinary().copy(_compressedData); | ||
@@ -158,2 +162,3 @@ _compressedData.write(_entryName, Utils.Constants.LOCHDR); | ||
_data = null; | ||
_needDeflate = false; | ||
}, | ||
@@ -186,3 +191,3 @@ | ||
} | ||
_entryHeader.method = _dataHeader.method; | ||
//_entryHeader.method = _dataHeader.method; | ||
@@ -216,3 +221,3 @@ _data = value; | ||
if (_entryHeader.commentLength) { | ||
header.write(_comment, Utils.Constants.CENHDR + _entryName.length + _entryHeader.extraLength) | ||
header.write(_comment, Utils.Constants.CENHDR + _entryName.length + _entryHeader.extraLength, _comment.length, 'utf8'); | ||
} | ||
@@ -219,0 +224,0 @@ return header; |
@@ -207,4 +207,8 @@ var ZipEntry = require("./zipEntry"), | ||
return outBuffer | ||
}, | ||
toAsyncBuffer : function(/*Function*/callback) { | ||
} | ||
} | ||
}; |
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
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
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
142043
33
2652
1
3