Here's the code I've been trying to use. I can't figure out why doesn't it work. It fails if I use any other flag. But even if it's successful, it doesn't return the size of the stream, so it's useless again (outBytes gets set to 0):
Code:
unsigned char *Unzip::unzipData(std::vector<unsigned char> data)
{
std::vector<unsigned char> outBuffer(1024 * 1024);
tinfl_decompressor inflator;
tinfl_status status;
tinfl_init(&inflator);
size_t inBytes = data.size();
size_t outBytes = 1024 * 1024;
status = tinfl_decompress(&inflator,
(const mz_uint8 *)&data[0],
&inBytes,
(mz_uint8 *)outBuffer.data(),
(mz_uint8 *)outBuffer.data(),
&outBytes,
TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF); <- I have no idea which flags to use. This is the only one that doesn't fail, but the outBytes is still 1.
outBuffer.resize(outBytes);
outBuffer.shrink_to_fit();
return /*something when the code actually starts working*/
}
This is the raw data I'm feeding it:
Data - Pastebin.com (EDIT: there's a byte missing right there at the beginning, it's 50 (char "P"))
Any idea why the code doesn't work?
I'm sorry, I've been at this for a week, and it's supposed to be the simplest thing. I'm tired and annoyed of it and I may come off as rude, which I don't want. Also, the linked library above deals with zip files. I have an array already loaded into memory. Writing it to disk only to be read again isn't really viable... The miniz seems like the simple solution I'm looking for, but I don't know why doesn't it work...