Question

While searching how to easy (without any dlls,...) unzip in C++, I came around Zip Utils.

I download data from server (compressed in PHP using gzencode()) to local buffer, now I'd like to uncompress it either using Zip Utils or something else.

Lets say I have :

char zipped[100000];

char unzipped[100000];

now I'd like to unzip data from one buffer to other, how exactly do I do that using Zip Utils?

EDIT: I've tried unzipping myself, but I cannot get it working. Here is the one example of how I tried.

 HZIP hz = OpenZip(zipped, sizeof zipped, "");
            char buf[1024]; ZRESULT zr = ZR_MORE; unsigned long totsize = 0;
            while (zr == ZR_MORE)
            {
                ZIPENTRY ze; GetZipItem(hz, 0, &ze);
                zr = UnzipItem(hz, 0, unzipped, sizeof unzipped);
                unsigned long bufsize = 1024; if (zr == ZR_OK) bufsize = ze.unc_size - totsize;
                    totsize += bufsize;
            }
            CloseZip(hz);
Was it helpful?

Solution

I've succeeded to solve my problem using source provided on this page

Probably the easiest code yet I saw, and it works flawlessly!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top