login about faq
0
1

I am doing upgrade testing on CkZip, the results are different between 9.4.0 and 9.5.0.47.
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 ) {
         zip.CloseZip();
         return false;
  }

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

  delete entry; entry = NULL;      
  zip.CloseZip();

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

}


ChilkatLog:
Copy:

DllDate: Oct  1 2014
ChilkatVersion: 9.5.0.44
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.
Failed.

--Copy
--ChilkatLog

--
Stanley

asked Apr 09 '15 at 00:34

Simopro's gravatar image

Simopro
8224

edited Apr 09 '15 at 00:39


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 http://www.chilkatsoft.com/refdoc/vcCkZipEntryRef.html ) See the information for the EntryType property, as well as the Copy method.

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

  • Mapped Entry: An entry in an existing Zip file.
  • File Entry: A file not yet in memory, but referenced. These entries are added by calling AppendFiles, AppendFilesEx, AppendOneFileOrDir, etc.
  • Data Entry: An entry containing uncompressed data from memory. These entries are added by calling AppendData, AppendString, etc.
  • Null Entry: An entry that no longer exists in the .zip.
  • New Directory Entry: A directory entry added by calling AppendNewDir.

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..

link

answered Apr 09 '15 at 10:17

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

Here is the example using CkCompression:

    CkCompression compress;

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

compress.put_Algorithm("deflate");
compress.put_EncodingMode("hex");

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

answered Apr 09 '15 at 10:53

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×87
×3

Asked: Apr 09 '15 at 00:34

Seen: 787 times

Last updated: Apr 09 '15 at 10:53

powered by OSQA