Sample code for 30+ languages & platforms
Ruby

Transition from ZipEntry.NextEntry to ZipEntry.GetNext

Provides instructions for replacing deprecated NextEntry method calls with GetNext.

Chilkat Ruby Downloads

Ruby
require 'chilkat'

success = false

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

zip = Chilkat::CkZip.new()

success = zip.OpenZip("qa_data/zips/xml_files.zip")
if (success != true)
    print zip.lastErrorText() + "\n";
    exit
end

# entry is a CkZipEntry
entry = zip.FirstEntry()
if (zip.get_LastMethodSuccess() == false)
    print "This zip archive is empty." + "\n";
    exit
end

finished = false
while finished == false

    if (entry.get_IsDirectory() == false)
        print entry.fileName() + "\n";
    else
        print "(directory) " + entry.fileName() + "\n";
    end

    # next is a CkZipEntry
    next = entry.NextEntry()
    if (entry.get_LastMethodSuccess() == false)
        finished = true
    end

    # entry is a CkZipEntry
    entry = next
end

zip.CloseZip()

print "----" + "\n";

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

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

ze = Chilkat::CkZipEntry.new()
zip.EntryAt(0,ze)

entryValid = true
while entryValid == true

    if (ze.get_IsDirectory() == false)
        print ze.fileName() + "\n";
    else
        print "(directory) " + ze.fileName() + "\n";
    end

    entryValid = ze.GetNext()
end

zip.CloseZip()