I read XZ's specification and I want to get uncompressed size. There is nothing like this in the footer or header.
Am I supposed to:
- read "Backward Size" from the header
- calculate: real_backward_size = (backward_size + 1) * 4;
- go to that offset
- skip a byte
- read variable length "Number of Records"
- read all the record where every record is 2 variable length values: "Unpadded Size", "Uncompressed size"
- sum all the "Uncompressed size" ? That looks super over-complicated.
Yes, what you described is correct, except you read the backward size from the footer of the .xz file, not the header. There can be zero padding, so you need to search backwards from the end of the file for the footer. You also need to continue to search for additional xz streams, since concatenated xz streams are valid .xz files.
Example in C: