This repository has been archived by the owner on Jun 2, 2024. It is now read-only.
Discussion: support for non-seekable reading #37
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I would like to read entries from an un-seekable stream, such as
stdin
.This pull request implements this by providing a
read_single
function that returns the next entry in the stream, orNone
if we've found the Central Directory, indicating the end of the file.Not all of the metadata is available, as it's not all stored in the local header. This code involves a bit of copy-paste, but not as much as I was expecting. It would be nice to restructure
ZipFileData
such that it had the "core" entries (the ones that are available in the local header, as I'm partially exposing asZipEntry
), and the extended entries separately.In terms of API.. uh. Java has ZipInputstream, which has an awful API. An archive could provide an iterator over entries, for non-seekable readers?
I also don't know what to do about discrepancies between the Central Directory and what the iterator has already returned, when using this API. Perhaps the
read_single
entry could return the contents of the Central Directory when it's encountered, to allow users to work out whether they've seen deleted, or otherwise invalid entries? An iterator could validate this at the end, andErr()
or something.zip64 is a mess, but it's currently not supported by the other code.