Sample code for 30+ languages & platforms
C++

Transition from ZipEntry.NextEntry to ZipEntry.GetNext

Provides instructions for replacing deprecated NextEntry method calls with GetNext.

Chilkat C++ Downloads

C++
#include <CkZip.h>
#include <CkZipEntry.h>

void ChilkatSample(void)
    {
    bool success = false;

    //  ------------------------------------------------------------------------
    //  The NextEntry method is deprecated.
    //  See below or code showing how to rewrite using EntryAt/GetNext

    CkZip zip;

    success = zip.OpenZip("qa_data/zips/xml_files.zip");
    if (success != true) {
        std::cout << zip.lastErrorText() << "\r\n";
        return;
    }

    CkZipEntry *entry = zip.FirstEntry();
    if (zip.get_LastMethodSuccess() == false) {
        std::cout << "This zip archive is empty." << "\r\n";
        return;
    }

    bool finished = false;
    while (finished == false) {

        if (entry->get_IsDirectory() == false) {
            std::cout << entry->fileName() << "\r\n";
        }
        else {
            std::cout << "(directory) " << entry->fileName() << "\r\n";
        }

        CkZipEntry *next = entry->NextEntry();
        if (entry->get_LastMethodSuccess() == false) {
            finished = true;
        }

        delete entry;
        entry = next;
    }

    zip.CloseZip();

    std::cout << "----" << "\r\n";

    //  ------------------------------------------------------------------------
    //  Do the equivalent using EntryAt/GetNext.

    success = zip.OpenZip("qa_data/zips/xml_files.zip");

    CkZipEntry ze;
    zip.EntryAt(0,ze);

    bool entryValid = true;
    while (entryValid == true) {

        if (ze.get_IsDirectory() == false) {
            std::cout << ze.fileName() << "\r\n";
        }
        else {
            std::cout << "(directory) " << ze.fileName() << "\r\n";
        }

        entryValid = ze.GetNext();
    }

    zip.CloseZip();
    }