pax global header support

This commit is contained in:
Mathias Buus 2014-05-30 14:23:25 +02:00
parent 8e77ad5f45
commit c097067528
3 changed files with 19 additions and 1 deletions

View file

@ -1,5 +1,6 @@
var util = require('util');
var bl = require('bl');
var xtend = require('xtend');
var headers = require('./headers');
var Writable = require('readable-stream').Writable;
@ -38,6 +39,7 @@ var Extract = function(opts) {
this._locked = false;
this._destroyed = false;
this._pax = null;
this._paxGlobal = null;
var self = this;
var b = self._buffer;
@ -66,9 +68,17 @@ var Extract = function(opts) {
oncontinue();
};
var onpaxglobalheader = function() {
var size = self._header.size;
self._paxGlobal = headers.decodePax(b.slice(0, size));
b.consume(size);
onstreamend();
}
var onpaxheader = function() {
var size = self._header.size;
self._pax = headers.decodePax(b.slice(0, size));
if (self._paxGlobal) self._pax = xtend(self._paxGlobal, self._pax);
b.consume(size);
onstreamend();
};
@ -87,6 +97,11 @@ var Extract = function(opts) {
oncontinue();
return;
}
if (header.type === 'pax-global-header') {
self._parse(header.size, onpaxglobalheader);
oncontinue();
return;
}
if (header.type === 'pax-header') {
self._parse(header.size, onpaxheader);
oncontinue();

View file

@ -32,6 +32,8 @@ var toType = function(flag) {
return 'contiguous-file';
case 72:
return 'pax-header';
case 55:
return 'pax-global-header'
}
return null;

View file

@ -10,7 +10,8 @@
"dependencies": {
"bl": "~0.6.0",
"end-of-stream": "~0.1.3",
"readable-stream": "~1.0.26-4"
"readable-stream": "~1.0.26-4",
"xtend": "^3.0.0"
},
"devDependencies": {
"tap": "~0.4.6",