Zip has a central directory you could just query, instead of having to construct one in-memory by scanning the entire archive. That's significantly less work.
That could work in a backwards-compatible way (as long as no standard tar utility makes modifications to the archive...), but it's hamfisted. Just use Zip. It's already a well-known format with numerous implementations and already does the job that you want to do.