Skip to content

Commit

Permalink
Merge pull request #135 from ZJONSSON/use-directory
Browse files Browse the repository at this point in the history
Use endOfDirectory file header instead of local header
  • Loading branch information
ZJONSSON authored Jun 1, 2019
2 parents 26edb18 + e81a932 commit ee69b43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/Open/directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ module.exports = function centralDirectory(source, options) {
})
.then(function(comment) {
vars.comment = comment;
vars.type = (vars.uncompressedSize === 0 && /[\/\\]$/.test(vars.path)) ? 'Directory' : 'File';
vars.stream = function(_password) {
return unzip(source, vars.offsetToLocalFileHeader,_password);
return unzip(source, vars.offsetToLocalFileHeader,_password, vars);
};
vars.buffer = function(_password) {
return BufferStream(vars.stream(_password));
Expand Down
5 changes: 4 additions & 1 deletion lib/Open/unzip.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var Buffer = require('../Buffer');
if (!Stream.Writable || !Stream.Writable.prototype.destroy)
Stream = require('readable-stream');

module.exports = function unzip(source,offset,_password) {
module.exports = function unzip(source,offset,_password, directoryVars) {
var file = PullStream(),
entry = Stream.PassThrough(),
vars;
Expand Down Expand Up @@ -44,6 +44,9 @@ module.exports = function unzip(source,offset,_password) {
.then(function(extraField) {
var checkEncryption;
vars.extra = parseExtraField(extraField, vars);
// Ignore logal file header vars if the directory vars are available
if (directoryVars && directoryVars.compressedSize) vars = directoryVars;

if (vars.flags & 0x01) checkEncryption = file.pull(12)
.then(function(header) {
if (!_password)
Expand Down

0 comments on commit ee69b43

Please sign in to comment.