Comparing version 0.9.9 to 0.9.10
@@ -62,4 +62,6 @@ var binary = require('binary'); | ||
return records.pull(vars.fileNameLength).then(function(fileName) { | ||
vars.path = fileName.toString('utf8'); | ||
return records.pull(vars.fileNameLength).then(function(fileNameBuffer) { | ||
vars.pathBuffer = fileNameBuffer; | ||
vars.path = fileNameBuffer.toString('utf8'); | ||
vars.isUnicode = vars.flags & 0x11; | ||
return records.pull(vars.extraFieldLength); | ||
@@ -66,0 +68,0 @@ }) |
@@ -82,4 +82,4 @@ var util = require('util'); | ||
return self.pull(vars.fileNameLength).then(function(fileName) { | ||
fileName = fileName.toString('utf8'); | ||
return self.pull(vars.fileNameLength).then(function(fileNameBuffer) { | ||
fileName = fileNameBuffer.toString('utf8'); | ||
var entry = Stream.PassThrough(); | ||
@@ -107,2 +107,6 @@ var __autodraining = false; | ||
entry.props.path = fileName; | ||
entry.props.pathBuffer = fileNameBuffer; | ||
entry.props.flags = { | ||
"isUnicode": vars.flags & 0x11 | ||
}; | ||
entry.type = (vars.uncompressedSize === 0 && /[\/\\]$/.test(fileName)) ? 'Directory' : 'File'; | ||
@@ -109,0 +113,0 @@ |
{ | ||
"name": "unzipper", | ||
"version": "0.9.9", | ||
"version": "0.9.10", | ||
"description": "Unzip cross-platform streaming API ", | ||
@@ -38,7 +38,8 @@ "author": "Evan Oxfeld <eoxfeld@gmail.com>", | ||
"aws-sdk": "^2.77.0", | ||
"dirdiff": ">= 0.0.1 < 1", | ||
"iconv-lite": "^0.4.24", | ||
"request": "2.79.0", | ||
"stream-buffers": ">= 0.2.5 < 1", | ||
"tap": ">= 0.3.0 < 1", | ||
"temp": ">= 0.4.0 < 1", | ||
"dirdiff": ">= 0.0.1 < 1", | ||
"stream-buffers": ">= 0.2.5 < 1" | ||
"temp": ">= 0.4.0 < 1" | ||
}, | ||
@@ -60,4 +61,4 @@ "directories": { | ||
"scripts": { | ||
"test": "tap test --jobs=10 --coverage-report=html --no-browser" | ||
"test": "tap test/*.js --jobs=10 --coverage-report=html --no-browser" | ||
} | ||
} |
@@ -165,2 +165,26 @@ [![NPM Version][npm-image]][npm-url] | ||
### Parse zip created by DOS ZIP or Windows ZIP Folders | ||
Archives created by legacy tools usually have filenames encoded with IBM PC (Windows OEM) character set. | ||
You can decode filenames with preferred character set: | ||
```js | ||
var il = require('iconv-lite'); | ||
fs.createReadStream('path/to/archive.zip') | ||
.pipe(unzipper.Parse()) | ||
.on('entry', function (entry) { | ||
// if some legacy zip tool follow ZIP spec then this flag will be set | ||
var isUnicode = entry.props.flags.isUnicode; | ||
// decode "non-unicode" filename from OEM Cyrillic character set | ||
var fileName = isUnicode ? entry.path : il.decode(entry.props.pathBuffer, 'cp866'); | ||
var type = entry.type; // 'Directory' or 'File' | ||
var size = entry.size; | ||
if (fileName === "Текстовый файл.txt") { | ||
entry.pipe(fs.createWriteStream(fileName)); | ||
} else { | ||
entry.autodrain(); | ||
} | ||
}); | ||
``` | ||
## Open | ||
@@ -167,0 +191,0 @@ Previous methods rely on the entire zipfile being received through a pipe. The Open methods load take a different approach: load the central directory first (at the end of the zipfile) and provide the ability to pick and choose which zipfiles to extract, even extracting them in parallel. The open methods return a promise on the contents of the directory, with individual `files` listed in an array. Each file element has the following methods: |
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
42360
19
829
302
7