streaming 7-Zip archive extractor
7zip#
streaming 7-Zip archive extractor
import { unsevenzip } from '@mary/7zip';
import { fromFsFile } from '@mary/7zip/deno';
// extracting a specific file from an archive
{
using file = await Deno.open('./archive.7z');
const reader = await fromFsFile(file);
for await (const entry of unsevenzip(reader)) {
console.log(entry.filename, entry.size);
if (entry.filename === 'mod.ts') {
console.log(await entry.text());
}
}
}
// password-protected, multi-volume archives — pass the volumes in order
{
using v1 = await Deno.open('./archive.7z.001');
using v2 = await Deno.open('./archive.7z.002');
const readers = [await fromFsFile(v1), await fromFsFile(v2)];
for await (const entry of unsevenzip(readers, { password: 'hunter2' })) {
console.log(entry.filename, await entry.bytes());
}
}