mszip | Decompresses MSZip compressed contents | Compression library
kandi X-RAY | mszip Summary
kandi X-RAY | mszip Summary
Decompresses MSZip compressed contents.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of mszip
mszip Key Features
mszip Examples and Code Snippets
Community Discussions
Trending Discussions on mszip
QUESTION
I have a compressed file that is a CAB that I wish to extract a file from in Linux. Since there aren't any native CAB extractors on Linux, I figured I'd try my hand at getting one done.
While I've seen the MSZIP documentation[0] as well as [1] and [2], I'm having difficulties in decompressing it even given that each Block is compressed using a modified DEFLATE compressor. While I did use [3] to decompress the blocks, aside for the first block, the rest of the blocks had a lot of missing data [data which were completely nulled [i.e. 0x00 filled].
So I'm lead to believe I'll need to figure it out manually.
Unfortunately, I am having trouble understanding [2]. So, with the following data:
...ANSWER
Answered 2021-Aug-07 at 20:12- No, the "basic concept" you thought you got from RFC 1951 is completely wrong. First off, the bits in each byte are read from least significant to most significant. Second, you do not reverse the bytes in the stream. The first eight bits are first read from the first byte, the second eight bits from the second byte, and so on. (Lengths in stored blocks are stored little-endian, but that is neither reversed nor not reversed. It is simply how a 16-bit length is serialized in the byte stream.)
- Once you read the bits correctly, the
HLIT
, etc. values are stored exactly as stated in the RFC. The first five bits are the number of literal/length codes minus 257. So you take the value of the five bits, which gives a number in 0..31, and add 257 to that. That gives a number in the range 257..288. The allowed range is actually 257..286 as noted on that same line, so the last two possible values of the five bits, 30 and 31, should not appear in a valid deflate stream. - RFC 1951 is not confusing at all. It is a clear and complete description of the format. However you need to have sufficient background in compression, in particular Huffman codes, to understand it. The RFC was not intended to be a textbook on compression, nor a textbook on how integers are coded in bits.
- It is clear it would take you some time to figure this all out. Fortunately, you do not need to write your own inflator. You can instead use zlib. Read the documentation in zlib.h for all of the
inflate
functions. - In CAB files, MSZIP CFDATA blocks use the history from previous CFDATA blocks, until a folder boundary is reached. Even though each block is a properly terminated deflate stream, the next block can refer to uncompressed data from the previous block. To process CFDATA blocks after the first, you will need to use the
inflateResetKeep()
function of zlib to restart the inflate process while retaining the dictionary from the previous inflate operation.
For reference, here is a decoding of the initial bytes of the deflate stream you provided, using infgen:
QUESTION
I have a small client application designed to run on windows machines. It is written in C/C++ (more in C). I want to keep it small and therefore I would prefer not to use external libraries and stick to WinAPI on client side.
On the other hand I have a backend server which is implemented in python3. Here I'm happy to use any existing lib. Now I want to add compression layer to increase transfer speed. The problem I've encountered is that it seems that WinAPI provides only:
...ANSWER
Answered 2020-May-08 at 11:24I found this Python script, and reverse-engineered it to produce a quick library to handle WinAPI Compression/Decompression. Basically, you can just use ctypes
and call the WinAPI from Python. Please keep in mind that I haven't extensively tested this, but it should give you a pretty good place to start :)
EDIT: As requested, I've included the implementations of the compress
and decompress
functions in case the links ever go down.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install mszip
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page