Ryan Jud Hughes wrote:
Write a header block and leave spaces for file size and checksum. Leave these as some constant value that indicates that they are placeholders. Then start writing the data, keeping track of the size of the file as we go. Once we've written all of it, seek back to the header block and fill in the size, and finally compute the checksum.
This would certainly work for your situation. The basic ustar archive format is pretty simple and it shouldn't be hard to write code from scratch to do this. None of the standard tar implementations work this way, however, because it's impossible to seek on tape drives or within compressed streams. Basically, if you want to use tar, you'll need to either figure out the data size in advance or write your own code. I suspect you'll find storing the data into a temporary file to be the simpler solution. ;-) You might also look into Zip libraries or tools. The Zip format has some extensions that are specially designed to support exactly this style of usage. Cheers, Tim Kientzle
