mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-08 05:27:04 +00:00
Examples way too simple, how to put in-memory files into an archive? #365
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @hopperpl on GitHub (Aug 16, 2019).
I have a lot of issues with the API and can't get my head around it. What I want to do just doesn't work, and the provided samples are way too primitive to be of any use. It is all about how to put a file into an archive. I'm not interested in the file system, I'm not using the file system at all. And I will certainly not write a temporary file and then read it back in.
What I need is an archive to access individual streams ("files") so the choice can only be zip. Each archive is 1-2 GB in size with around 10,000 files and I need random file access. The compression should be LZMA at maximum settings. And the zip file should not be blown up with enhanced attributes, DACL settings all that -- only the basics.
My input is a byte[] with a key ("name") that I compress with LzmaStream() (new LzmaStream(new LzmaEncoderProperties(false, 16 << 20, 273), false, ...). Now I have the compressed byte[] and what's next? How do I put this into a zip archive?
Of course that doesn't work, there is no option to set the compression. There are no options whatsoever anywhere in ZipArchive, in the Create method or in AddEntry. It's all just a magic black box that doesn't work at all as I want it to. And also it doesn't help to give AddEntry a LzmaStream as that streams writes to an output stream, so either AddEntry gets a stream with compression info but no data or a data stream without compression info. In my head I have so much trouble to even get the concept: And it should be easy. AddEntry(Key, RawInputStream, CompressionFormatAndSettings) for a pull concept and Stream GetNewEntryStream(Key, CompressionFormatAndSettings) for a push concept.
So what are my options here? Why is there no functionality to say... ZipAchive, add stream with LZMA and the LzmaEncoderProperties.
And also, why is there no function to access the raw stream of a ZipArchive? How can I transfer a stream from one zip to another keeping it compressed?
Some examples that are not so utterly basic would help a lot.
@adamhathcock commented on GitHub (Aug 21, 2019):
If you'd like something that isn't "utterly basic" then the tests cover a lot.
You're welcome to suggest actual improvements or pull requests to cover options that aren't exposed.