News:

Download Pelles C here: http://www.pellesc.se

Main Menu

LiteZip tests

Started by TimoVJL, Yesterday at 08:53:52 PM

Previous topic - Next topic

TimoVJL

LiteZip 2008 version tests with static libraries.

Check this too
https://www.wischik.com/lu/programmer/zip_utils.html
May the source be with you

Vortex

#1
Hi Timo,

Thanks for the static libraries. With the help of ChatGPT, here is an unzip sample :

// Dependencies required to build the project
// LiteUnzip.h and LiteUnzip.lib from LiteUnzip_WS2.zip
// https://forum.pellesc.de/index.php?msg=42339
// Sample code by ChatGPT

#include <windows.h>
#include <stdio.h>
#include "LiteUnzip.h"

int main(void)
{
    HUNZIP hz;
    ZIPENTRY ze;
    DWORD numitems, i;

    // Open ZIP
    if (UnzipOpenFileA(&hz, "test.zip", 0) != 0)
    {
        printf("Cannot open ZIP file\n");
        return 1;
    }

    // Get number of items
    ze.Index = (DWORD)-1;
    if (UnzipGetItemA(hz, &ze) != 0)
    {
        printf("Cannot get ZIP info\n");
        UnzipClose(hz);
        return 1;
    }

    numitems = ze.Index;
    printf("Files in archive: %lu\n", numitems);

    // Extract loop
    for (i = 0; i < numitems; i++)
    {
        ze.Index = i;

        if (UnzipGetItemA(hz, &ze) != 0)
        {
            printf("Error reading item %lu\n", i);
            continue;
        }

        printf("Extracting: %s\n", ze.Name);

        if (UnzipItemToFileA(hz, ze.Name, &ze) != 0)
        {
            printf("Failed to extract %s\n", ze.Name);
        }
    }

    UnzipClose(hz);
    return 0;
}
Code it... That's all...