You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to generate an index of a tar file with the start and end offset of each file in the tarball, such that I can mmap or extract a single file later on. Is this possible with tar-stream?
The documentation of headers only mentions the size of each file, but I would also need the offset within the tar.
From hacking it looks like the global property extract._buffer.shifted contains what I need but this is mostly a guess. It would be nice if the header callback could include the offset property for each entry.
The text was updated successfully, but these errors were encountered:
Here is what I puzzled together. Does this seem right? Is there a more efficient way to do this:
constfs=require('fs')consttar=require('tar-stream')constgunzip=require('gunzip-maybe');functiontar_index(path){constinput=fs.createReadStream(path);constextract=tar.extract();letoutput=[];returnnewPromise(function(resolve,reject){functionprocess_entry(header,stream,next){varoffset=extract._buffer.shifted//console.log(stream)output.push({name: header.name,offset: offset,size: header.size});stream.on('end',function(){next()//read for next file})stream.on('error',reject);stream.resume();}functionfinish_stream(){resolve(output);}varextract=tar.extract({allowUnknownFormat: true}).on('entry',process_entry).on('finish',finish_stream).on('error',reject)input.pipe(gunzip()).pipe(extract);}).finally(function(){input.destroy();});}tar_index('myfile.tar.gz').then(console.log)
I would like to generate an index of a tar file with the start and end offset of each file in the tarball, such that I can mmap or extract a single file later on. Is this possible with tar-stream?
The documentation of headers only mentions the size of each file, but I would also need the offset within the tar.
From hacking it looks like the global property
extract._buffer.shifted
contains what I need but this is mostly a guess. It would be nice if theheader
callback could include the offset property for each entry.The text was updated successfully, but these errors were encountered: