Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
gname: '',
devmaj: 0,
devmin: 0,
atime: null,
ctime: null,
nullBlock: false
}
t.match(h, expect)
t.equal(data.length, 2048)
t.match(data.slice(1024).toString(), /^\0{1024}$/)
const syncgz = new PackSync({ cwd: files, portable: true, gzip: true })
.add('dir').end().read()
t.equal(syncgz[9], 255, 'gzip OS flag set to "unknown"')
const sync = new miniz.Gunzip().end(zipped).read()
t.equal(sync.slice(512).toString(), data.slice(512).toString())
const hs = new Header(sync)
t.match(hs, expect)
const expect2 = {
type: 'File',
cksumValid: true,
needPax: false,
path: 'dir/x',
mode: 0o644,
size: 0,
mtime: mtime,
cksum: Number,
linkpath: '',
uname: '',
module.exports = function tar (cacheDir, destDir) {
debug(() => `untar ${cacheDir} ${destDir}`);
const gunzip = new zlib.Gunzip();
const extractStream = tarStream.extract();
extractStream.on('entry', (header, stream, next) => {
if (header.type !== 'file') {
stream.resume();
stream.on('end', next);
return;
}
const name = header.name.slice(header.name.indexOf('/'));
if (!cacheDir) {
writeOne(destDir + name, stream, next);
return;
}
if (!destDir) {
writeOne(cacheDir + name, stream, next);
return;
}
function fastPathGunzip(bufferOrString, options) {
const stream = new Gunzip(options)
if (options.encoding === "utf8") {
let result = ""
stream.on("data", (chunk) => result += chunk).end(bufferOrString)
return result
}
return streamToBuffer(stream, bufferOrString)
}
static gunzip(bufferOrString, options) {
options = typeof options === "string" ? { encoding: options } : options
options = utils.createOptions(options)
if (useGunzipFastPath) {
try {
const stream = new minizlib.Gunzip(options)
if (options.encoding === "utf8") {
let result = ""
stream.on("data", (chunk) => result += chunk).end(bufferOrString)
return result
}
return streamToBuffer(stream, bufferOrString)
} catch (e) {
useGunzipFastPath = false
}
}
return fallbackGunzip(bufferOrString, options)
}