Archived Forum Post

Index of archived forum posts

Question:

CkZip DeleteEntry() crashes

Jul 18 '13 at 17:06

I downloaded the release version of 9.4.1 yesterday. This is the code which worked perfectly with 9.3.2:

WIN32_FIND_DATA FindFileData;
HANDLE hFind;
CkZipEntry *entry = 0;
int continue = 1;
hFind = FindFirstFile(szPath, &FindFileData);
while ((continue == 1) && (hFind != INVALID_HANDLE_VALUE)) {
    entry = zip.FirstMatchingEntry(FindFileData.cFileName);
    if (entry != NULL) {
        zip.DeleteEntry(entry);
    }
    if (FindNextFile(hFind, &FindFileData) == 0) {
        continue = 0;
    }
}
(void)FindClose(hFind);
delete entry;

Now, compiling this code with 9.4.1 results in a error: 'CkZip::DeleteEntry' : cannot convert parameter 1 from 'CkZipEntry *' to 'CkZipEntry &'

Attempting to use a pointer or cast results in a crash at runtime. I downloaded the chilkat-9.4.1-x86-vc9-sp1 archive.

"DeleteEntry" can no longer be found in the CkZip documentation, is there a reason for this?


Answer

In v9.4.1, methods that have Chilkat objects for arguments will pass them by reference instead of via pointers. For example:

    bool DeleteEntry(CkZipEntry &entry);
Your code should look like this:
    entry = zip.FirstMatchingEntry(FindFileData.cFileName);
    if (entry != NULL) {
        zip.DeleteEntry(*entry);
    }

The online reference documentation and release notes will be updated ASAP. The underlying reason for the changes is for consistency for generating various kinds of wrappers (for Objective-C, DLL functions, and as many will find out in the near future, C++/CX and Mono C# wrappings). It's been a long migration path, but in general, Chilkat is moving in the direction where everything at the outer-layers is auto-generated by an internally defined API spec, and this allows for potential changes and improvements across-the-board at the outer layers of any API.

For v9.4.1, if there is a compile error, check the class definition. For example, you may find that an argument previously declared as "long" is now an "int".


Answer

Thank you. I made the change in my code, but as I still getting a crash with 9.4.1.0, I am stepping through the code in the debugger. I get an access violation when executing zip.QuickAppend(szZipFile). I don't see a mention in the documentation that here was a change.