diff -r 89d6a7a84779 -r 25a17d01db0c Symbian3/PDK/Source/GUID-84922B27-FDCF-56FD-91ED-5E0BFE3ED0E4.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/PDK/Source/GUID-84922B27-FDCF-56FD-91ED-5E0BFE3ED0E4.dita Fri Jan 22 18:26:19 2010 +0000 @@ -0,0 +1,147 @@ + + + + + +Compressing +and Decompressing File - Zip Format The Zip Compression Library, EZLib provides stream and file compression +and decompression functionality for the Symbian platforms. The files can be +compressed to two formats namely zip and gzip. Compression and Decompression +are performed iteratively, till the completion of required task. + + +Pass the input and +output files as parameters to construct an instance of CEZFileBufferManager. +This returns a pointer to CEZFileBufferManager (input buffer). + CEZFileBufferManager provides functions that accept +and converts the data into buffers for MEZBufferManager class +to manage it internally. + + +Pass the input buffer and other compression parameters to the object +of the CEZCompressor class. + + +Use CEZCompressor::DeflateL() to compress the file. + + +

The following code demonstrates a compression procedure.

/* + * Compresses the file into a zip file using the EZlib component. + * It is assumed that the input and output file names are contained in a + * provided ini file. + */ + + +void CEZlibEZipTests::DoEZlibDeflateL() + { +RFs iFs; + iFS.connect(); + + + + //Open input file +_LIT(KInputFileLocation, "c:\\private\\E80000B7\\zip\\input\\input.doc"); +TFileName inputFile(KInputFileLocation); + RFile input; + err = input.Open(iFs, inputFile, EFileStream | EFileRead | EFileShareExclusive); + if(err != KErrNone) + { + INFO_PRINTF1(KOpenFileError); + User::Leave(err); + } + + + + //open output file + +_LIT(KOutputFileLocation, "c:\\private\\E80000B7\\zip\\input\\output.zip"); +TFileName outputFile(KOutputFileLocation); + RFile output; + err = output.Replace(iFs, outputFile, EFileStream | EFileWrite | EFileShareExclusive); + if(err != KErrNone) + { + INFO_PRINTF1(KCreateFileError); + User::Leave(err); + } + + + + CEZFileBufferManager *bufferManager = CEZFileBufferManager::NewLC(input, output); + CEZCompressor *compressor = CEZCompressor::NewLC(*bufferManager, aLevel, aWindowBits, aMemLevel, aStrategy); + + while(compressor->DeflateL()) + { + } + output.Close(); +input.Close(); + iFS.Close(); + + + + } +
+

The decompression of a .zip file can be achieved +through the following the steps:

    +
  1. Pass the +input and output files as parameters to construct an instance of CEZFileBufferManager. +This returns a pointer to CEZFileBufferManager ( buffer).

  2. +
  3. Pass the buffer to the +object of the CEZDecompressor class.

  4. +
  5. CEZDecompressor::InflateL() is +called repeatedly until the decompression is complete.

  6. +

The following code demonstrates the decompression procedure.

/* Decompresses the file contained in a Zip file using the EZlib component. + * It is assumed that the input and output file names are contained in a + * provided ini file. + */ + +void CEZlibEZipTests::DoEZlibInflateL() + { +RFs iFs; + iFS.connect(); + +//Open input file +_LIT(KInputFileLocation, "c:\\private\\E80000B7\\zip\\input\\output.zip"); +TFileName inputFile(KInputFileLocation); + RFile input; + err = input.Open(iRfs, inputFile, EFileStream | EFileRead | EFileShareExclusive); + if(err != KErrNone) + { + INFO_PRINTF1(KOpenFileError); + User::Leave(err); + } + + + + //open output file + +_LIT(KOutputFile, "c:\\private\\E80000B7\\zip\\input\\input.doc"); +TFileName outputFile(KOutputFile); + RFile output; + err = output.Replace(iFs, outputFile, EFileStream | EFileWrite | EFileShareExclusive); + if(err != KErrNone) + { + INFO_PRINTF1(KCreateFileError); + User::Leave(err); + } + + + +CEZFileBufferManager *bufferManager = CEZFileBufferManager::NewLC(input, Output); +CEZDecompressor *decompressor = CEZDecompressor::NewLC(*bufferManager, aWindowBits); + + + while(decompressor->InflateL()) + { + } +output.Close(); + input.Close(); + ifs.Close(); + + }
+
\ No newline at end of file