Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

Add by_name_seek() for Stored zips #369

Closed
wants to merge 1 commit into from
Closed

Conversation

exFalso
Copy link

@exFalso exFalso commented May 10, 2023

This PR adds a ZipArchive::by_name_seek function which returns a ZipFileSeek structure that implements Seek.
This only works for Stored types of zips for now, although I'm sure this can be implemented for compressed archives as well using some kind of lazy indexing structure that helps map compressed indexes to uncompressed ones quickly.

I tried various ways of adding this feature, but I could only make it work like this. I "forked" the ZipFile structure, added a ZipFileSeek, and added a common trait that implements the metadata goodies. The reason I couldn't make it work with a unified approach is because the current library supports non-Seek base readers, and there's no such thing as a dynamic cast in Rust (nor would I want there to be).

One consequence of the trait is that this change became API breaking, as the trait must be imported to access the metadata functions. I can add back the original functions that dispatches to the trait in case this is an issue.

Although I have not added tests to this crate, it has been tested fairly thoroughly with tests testing our own usage of the feature.

@exFalso
Copy link
Author

exFalso commented May 10, 2023

Linking with issue https://github.com/zip-rs/zip/issues/223

@Pr0methean
Copy link
Member

Replaced with zip-rs/zip2#69.

@Pr0methean Pr0methean closed this May 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants