mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-06 13:34:58 +00:00
Question: How to get XZ uncompressed size #455
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 @x1unix on GitHub (Apr 26, 2021).
Hello, as far as I know XZ format has index section which contains archive metadata (most notably - uncompressed size).
I've skimmed through XZ implementation in this package and looks like sharpcompress can read XZ index, but it's impossible to get XZBlock information without reading and decompressing whole archive contents.
How can I get XZ index information using this library without extracting archive contents?
It would nice to have to populate uncompressed stream size in
Lengthproperty.@adamhathcock commented on GitHub (Apr 26, 2021):
If it's in the metadata, then it's something that's just been overlooked for whatever reason. Should be a relatively quick thing to do.
@x1unix commented on GitHub (Apr 26, 2021):
@adamhathcock as far as I understand, uncompressed size can be calculated by reading
XZIndex, but currently there is no known option to read only archive structure without unarchiving Xz contents (asXZStreamreturns extracted archive contents).XZIndexbecomes available only after a whole archive was read:XzStream.cs
@x1unix commented on GitHub (Apr 26, 2021):
Similar issue in related lzma project - https://github.com/addaleax/lzma-native/issues/15
Might be useful for implementation.
@adamhathcock commented on GitHub (Jun 4, 2021):
Zip has the same issue with streamed files where you don't know the size before compression.
We should be able to implement this size on XZ when using Archive strategy but not Reader strategy
@x1unix commented on GitHub (Jul 13, 2021):
@adamhathcock here is a simple snippet to calculate uncompressed size of XZ contents. Hope it helps.
Works only with seekable streams. For non-seakable streams, a whole file should be read before.