Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: nice api for ArchiveExtractCallback/ISequentialOutStream #122

Open
1 task done
RScherzer opened this issue Feb 17, 2023 · 2 comments
Open
1 task done
Assignees
Milestone

Comments

@RScherzer
Copy link

Feature description

Would be great if there would be an easy, clean interface in 4.x for adding a callback which is able to work on the currently decompressed block of data, so you can e.g. calculate the sha1 hash value of a file while it is being decompressed blockwise to memory.
In 7z sdk theory this is an archive Extract call in test mode with ArchiveExtractCallback + ISequentialOutStream specified which inits the hash calculation, doing the hash update during the streams write calls and finalizing the hash when the extractcallback does its SetOperationResult.

Additional context

No response

Code of Conduct

@rikyoz
Copy link
Owner

rikyoz commented Feb 26, 2023

Hi!
Sorry for the late reply!

Would be great if there would be an easy, clean interface in 4.x for adding a callback which is able to work on the currently decompressed block of data, so you can e.g. calculate the sha1 hash value of a file while it is being decompressed blockwise to memory.

I think it would be a great feature indeed, I will definitely add it to the library.
Thanks for the suggestion!

In 7z sdk theory this is an archive Extract call in test mode with ArchiveExtractCallback + ISequentialOutStream specified which inits the hash calculation, doing the hash update during the streams write calls and finalizing the hash when the extractcallback does its SetOperationResult.

Yeah, I need to find out the best API for providing the feature.
I have some ideas which I need to test out.

I consider the v4.0 feature complete, so I'll probably add this feature to the next v4.1.

@rikyoz rikyoz added this to the v4.1 milestone Feb 26, 2023
@RScherzer
Copy link
Author

I've implemented it myself already (not worth or already nice enough for a pull request).

Generally I've added 2 callbacks to bitAbstractArchiveHandler

  • one which hooks into ExtractCallback::GetStream and allows the callback to set its own outStream instead of using the default implementation
  • one which is called in SetOperationResult
  • additionally I've added the single test feature from my other feature request (which is pretty straight forward adding another testArc and test in bitinputarchive.cpp)

So when I want to calculate a sha1 from a single compressed file, I set up the 2 callbacks.
The GetStream one setups a new ISequentialOutStream which calls the sha1 update in its write method and the sha1 finalize is called in the SetOperationResult callback.
To trigger the callbacks I do a single entry test operation after setting up the callbacks.

As I said...not yet in an api-nice way, but functional ;-)

Having the stream-replace callback I will be able to solve my "give the decompressed files different names", too.

Thanks for your support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants