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>
Sun, 10 Feb 2019 00:00:47 +0000 (16:00 -0800)
commit56c91a598fef068907bd8de975d5f49b9c02a045
tree93c29d97e4d83795e7ef073e6dbe2fe0ff8f7bb9
parentd600b923ee26399f86e63e6e1a6d90ddaeb571d6
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