Open wojtaszg opened 4 years ago
Sorry for the delay, my GitHub notification settings must be wrong... And no, the client only requested decompressing raw LZMA2 files, and it was complete evil to work with raw bytes in JS, so I'm not willing to port it myself; this was only to satisfy a client. In addition, there's a wrapper I gave to the client which downloads the JS hosted on GitHub via XmlHttpRequest; so it's both open-source for others to not do the work I've done for LZMA2, and because my apps actually rely on a public URL - altho they try local site first.
If you're trying to reverse-engineer, in my scenario I ended up opening a Java LZMA2 program in Visual Studio Code (since the original LZMA-JS was based on a Java program), and stepping through the JS and Java together, comparing each line; I also uploaded an expected-result byte array and checked for match each time a byte was written.
If it helps, it is possible to pass LZMA2 chunks inside XZ using this app; LZMA2 has a single-byte property header which is all you should need. The chunks themselves are either uncompressed LZMA2 with size, or compressed, in which case both compressed and uncompressed sizes are in the chunk's header as 16-bit integers, if memory serves.
Hope that helps you with your quest, sorry I'm not in a position to do this for ya. I'll accept any pull requests if you do defeat the dragon though.
First, thank you so much @SortaCore for this effort! I was ripping my hair off until I realized that the data inside an xz archive is in fact LZMA2, which is not supported by the base LZMA-JS. So this one is a lifesaver.
@wojtaszg — xz is a container format and as such has a few headers around the actual LZMA{,2} data. I have created this gist demonstrating a (very crude) way to extract a block of data and decompress it with lzma2_decompress
. It only supports archives that have exactly one block; files intended for streaming may have multiple. It should not be hard to adapt the code to support any number of blocks.
Hi, I tried to decompress .xz file using lzma2_decompress function, but I didn't manage to do it. I read .xz file as a byte array and passed it to function as parameter. The function returned "undefined" and it wasn't possible to see decompressed file data. Is it possible to decompress .xz file using this library?