cpio-stream
is a streaming cpio packer. It is basically the cpio
version on
tar-stream.
Extraction
odc
/old character
newc
/new character
crc
/new crc
note: checksum will not be tested nor rejected!
Packing
odc
/old character
Mostly following the libarchive documentation documentation. Feel free to create pull requests to add additional format support!
var cpio = require('cpio-stream')
var pack = cpio.pack()
pack.entry({name: 'my-test.txt'}, 'hello, world\n')
var entry = pack.entry({'my-stream-test.txt', size: 11}, function (err) {
// stream was added
// no more entries
pack.finalize()
})
entry.write('hello')
entry.write(' world')
entry.end()
// pipe the archive somewhere
pack.pipe(process.stdout)
var extract = cpio.extract()
extract.on('entry', function (header, stream, callback) {
stream.on('end', function () {
callback()
})
stream.resume() // auto drain
})
extract.on('finish', function () {
// all entries read
})
pack.pipe(extract)
MIT, with some of the code taken from the tar-stream
module by @mafintosh