Unicode C
Unicode C
Transition from Zip.AppendBd to Zip.AddBd
Provides instructions for replacing deprecated AppendBd method calls with AddBd.Chilkat Unicode C Downloads
#include <C_CkZipW.h>
#include <C_CkBinDataW.h>
#include <C_CkZipEntryW.h>
void ChilkatSample(void)
{
BOOL success;
HCkZipW zip;
const wchar_t *pathInZip;
HCkBinDataW bd;
HCkZipEntryW entryObj;
HCkZipEntryW ze;
int index;
success = FALSE;
zip = CkZipW_Create();
// ...
// ...
pathInZip = L"example.dat";
bd = CkBinDataW_Create();
CkBinDataW_LoadFile(bd,L"c:/someDir/example.dat");
// ------------------------------------------------------------------------
// The AppendBd method is deprecated:
// AppendBd returns the zip entry object, which is usually not needed.
entryObj = CkZipW_AppendBd(zip,pathInZip,bd);
if (CkZipW_getLastMethodSuccess(zip) == FALSE) {
wprintf(L"%s\n",CkZipW_lastErrorText(zip));
CkZipW_Dispose(zip);
CkBinDataW_Dispose(bd);
return;
}
// ...
// ...
CkZipEntryW_Dispose(entryObj);
// ------------------------------------------------------------------------
// Do the equivalent using AddBd.
// Instead of returning the zip entry object, we just return success/failure.
success = CkZipW_AddBd(zip,pathInZip,bd);
if (success == FALSE) {
wprintf(L"%s\n",CkZipW_lastErrorText(zip));
CkZipW_Dispose(zip);
CkBinDataW_Dispose(bd);
return;
}
// Do the following if you need the zip entry object for what was just appended.
// The newly appended entry is the last one.
ze = CkZipEntryW_Create();
index = CkZipW_getNumEntries(zip) - 1;
CkZipW_EntryAt(zip,index,ze);
CkZipW_Dispose(zip);
CkBinDataW_Dispose(bd);
CkZipEntryW_Dispose(ze);
}