Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
archive.on('close', function () {
console.log('+++++++++++')
yauzl.open(join(__dirname, '/test-alt.zip'), function (err, zip) {
if (err) console.log('err', err)
zip.on('entry', function (entry) {
// console.log(entry);
child.same(entry.fileName, file1Alt)
child.same(entry.compressedSize, 11)
child.same(entry.uncompressedSize, 20)
})
zip.on('close', function () {
child.end()
})
})
})
child.type(archive, 'object')
export default function processCompressedFile (mainWindow, zipParams) {
yauzl.open(zipParams.filePath, zipParams.options, (err, zipFile) => {
if (err) throw err
zipFile.on('error', (err) => {
throw err
})
zipFile.on('entry', (entry) => {
// console.log('File:', entry.fileName)
zipFile.openReadStream(entry, (err, readStream) => {
if (err) throw err
if (zipParams.target === entry.fileName) {
saveFile(mainWindow, zipParams, entry.fileName, readStream)
}
})
})
return new Promise(function(fulfill, reject) {
var unzips = [];
yauzl.open(zipPath, function(err, zipfile) {
if (err) {
reject(err);
return;
}
zipfile
.on('entry', function(entry) {
if (/\/$/.test(entry.fileName)) {
return;
}
zipfile.openReadStream(entry, function(err, readStream) {
var lastSlashIdx = entry.fileName.lastIndexOf('/'),
fileName = entry.fileName.substr(lastSlashIdx + 1),
filePath = path.join(targetPath, fileName);
if (err) {
reject(err);
return;
function unzipFile(file,cb) {
console.log(file);
yauzl.open(file, {
autoClose: false
}, function(err, zipfile) {
if (err) throw err;
filingQueue.drain = null;
zipfile.on('entry', function(entry) {
if (entry.fileName.indexOf('.fec') !== -1) {
filingQueue.push({
name: entry.fileName,
openStream: function (cb) {
zipfile.openReadStream(entry, cb);
}
});
return Promise.fromCallback(callback => {
return Zip.open(this.apk, {lazyEntries: true}, callback)
})
}
return new Promise((resolve, reject) =>
zip.open(zipPath, { lazyEntries: true }, (err, zipfile) => {
if (err) {
reject(err);
} else {
zipfile.readEntry();
zipfile.on('entry', (entry: zip.Entry) => {
callback(entry).then(outstream => {
if (outstream != null) {
zipfile.openReadStream(entry, (err, zipstream) => {
if (err) {
reject(err);
} else {
outstream.on('error', reject);
zipstream.on('error', reject);
zipstream.on('end', () => zipfile.readEntry());
zipstream.pipe(outstream);
}
return P.fromCallback(cb => yauzl.open(file_path, UNZIP_OPTIONS, cb));
}
return new Promise((resolve, reject) => {
yauzl.open(input, { lazyEntries: true }, (err, zipfile) => {
if (err) {
reject(err);
}
zipfile.readEntry();
zipfile.on('close', () => {
resolve();
});
zipfile.on('error', err => {
reject(err);
});
zipfile.on('entry', entry => {
const zipPath = entry.fileName
return new Promise((resolve, reject) => {
yauzl.open(archivepath, { lazyEntries: true }, (error, zipfile) => {
if (error) return reject(error)
zipfile.readEntry()
zipfile.on('entry', (entry) => {
if (entry.fileName !== entrypath) {
return reject(new Error('Unexpected file in archive'))
}
zipfile.openReadStream(entry, (error, readStream) => {
if (error) return reject(error)
readStream.on('error', reject)
const file = createWriteStream(csvpath)
readStream.pipe(file)
readStream.on('end', resolve)
})
})
zipfile.on('end', () => reject(new Error('Empty archive')))
})
function unzip () {
yauzl.open(filePath, { lazyEntries: true }, (error, zip) => {
if (error) throw error
utils.logAction('Unzipping...\n')
zip.on('entry', entry => isFolder(entry) ? zip.readEntry() : unzipEntry(zip, entry))
zip.on('end', resolve)
zip.readEntry()
})
}
})