zip-reader: Read the whole central directory at .zip open time.
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 16 Jul 2017 03:22:10 +0000 (20:22 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Fri, 11 Oct 2019 04:07:41 +0000 (04:07 +0000)
commitdb7d86c511e47ccbf28263889c8060fd3a97edbc
tree44f173922aac2433dda834177c794f4ecbb69639
parent4dcaaab90ea7f9a38a35bbc587712d6d9c260a3c
zip-reader: Read the whole central directory at .zip open time.

By reading the whole central directory when we open the .zip file, rather
than one entry at a time, we make it easier to get a list of entries and
make it available to the client.  (This will be implemented in an upcoming
commit.)

This commit also fixes memory leaks in the error case in zip_member_open().

This commit also changes the usage model.  Previously, if the caller opened
a single member more than once, all the members shared a single copy of
the member and read each other's data.  Now, each caller that opens a
member gets a separate copy and a separate file pointer.  Callers now need
to call zip_member_finish() when they're done with a member.

With this commit, the code only keeps an open FILE for a member if the
caller opened that member.  Previously, it kept an open FILE for any
member that had been encountered.
src/data/ods-reader.c
src/libpspp/zip-reader.c
src/libpspp/zip-reader.h
tests/libpspp/zip-test.c