Archived Forum Post

Index of archived forum posts


[CkZip] Copy() function has different result between 9.4.0 and

Apr 09 '15 at 10:53

I am doing upgrade testing on CkZip, the results are different between 9.4.0 and
Could you please check it for me? I need to zip/unzip byteDate only in memory without zip file output.
I expect copy() provides compressed data, which success in 9.4.0, but failed in 9.5.0.x.
The function implements as following,

bool ZipByte(IN CkByteData& dbRawData, OUT CkByteData& dbCompres) {

  CkZip zip;

  if ( !zip.UnlockComponent(unlockKey) )
         return false;
  if ( !zip.NewZip(unusedFilename) )
         return false;

  CkZipEntry* entry = zip.AppendData(unusedFilename, dbRawData);
  if ( entry == NULL ) {
         return false;

  if ( !entry->Copy(dbCompres) ) /*** failed in new version:9.5.0.x. ***/  
         delete entry; entry = NULL;      
         return false;

  delete entry; entry = NULL;      

  std::cout << dbCompres.getEncoded("hex") << std::endl;
  return true;



DllDate: Oct  1 2014
UnlockPrefix: ----------
Username: xxxxxxxxxx:uuuuuuuu
Architecture: Little Endian; 32-bit
Language: Visual C++ 8.0 (32-bit)
VerboseLogging: 1
Must be an entry within an opened zip archive.



Accepted Answer

Thanks. The old version would try to compress the data if the entry was not already a "mapped entry". This was very problematic for many reasons, and that functionality was removed for a simpler implementation that is more explicitly driven by the application.

I updated the reference documentation for the ZipEntry object. (See ) See the information for the EntryType property, as well as the Copy method.

In summary, an entry can be one of the following types:

When the zip is written by calling WriteZip or WriteToMemory, all of the zip entries are transformed into mapped entries. They become entries that contain the compressed data within the .zip that was just created. (The WriteZip method call effectively writes the zip and then opens it, replacing all of the existing entries with mapped entries.)

A better solution is to use CkCompression instead of CkZip if you only want to compress data. You would use the "deflate" compression algorithm. The CkCompression object has been part of the "Zip license" for a long time now, so you may use your Zip unlock code with CkCompression in the newer version.

I'll post a CkCompression example shortly that can be used to replace your code above..


Here is the example using CkCompression:

    CkCompression compress;

CkByteData dbIn;
bool success = dbIn.loadFile("qa_data/hamlet.xml");
if (!success) return false;


std::cout &lt;&lt; compress.compressBytesENC(dbIn) &lt;&lt; std::endl;