How are zlib, gzip and Zip related? (2013)
It seems like it wouldn&#x27;t be that hard to create an indexed tar.gz format that&#x27;s backwards compatible.<p>One way would be to use the last file in the tar as the index, and as files are added, you can remove the index, append the new file, append some basic file metadata and the compressed offset (maybe of the deflate chunk) into the index, update the index size in bytes in a small footer at the end of the index, and append to the compressed tar (add).<p>You can retrieve the index by starting at the end of the compressed archive, and reading backwards until you find a deflate header (at most 65k plus a few more bytes, since that&#x27;s the size of a deflate chunk), If it&#x27;s an indexed tar, the last file will be the index, and the end of the index will be a footer with the index size (so you know the maximum you&#x27;ll need to seek back from the end).  This isn&#x27;t extremely efficient, but it is limited in scope, and helped by knowing the index size.<p>You could verify the index by checking some or all of the reported file byte offsets.  Worst case scenario is small files with one or more per deflate chunk, and you would have to visit each chunk.  This makes the worst case scenario equivalent to listing files an un-indexed tar.gz, plus the overhead of locating and reading the index (relatively small).<p>Uncompressing the archive as a regular tar.gz would result in a normal operation, with an additional file (the index) included.<p>I imagine this isn&#x27;t popular is not because it hasn&#x27;t been done, but because most people don&#x27;t really need an index.