Symbian3/PDK/Source/GUID-548CC331-8E38-5627-A925-EA386BE90258.dita
changeset 1 25a17d01db0c
child 3 46218c8b8afa
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE task
       
    11   PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
       
    12 <task id="GUID-548CC331-8E38-5627-A925-EA386BE90258" xml:lang="en"><title>Compressing
       
    13 and Decompressing File - GZip Format </title><abstract><shortdesc>The Zip Compression Library, EZLib provides file compression
       
    14 and decompression functionality for the Symbian platforms. The files can be
       
    15 compressed to two formats namely zip and gzip. gzip is normally used to compress
       
    16 single files. </shortdesc> <p/> </abstract><prolog><metadata><keywords/></metadata></prolog><taskbody>
       
    17 <context id="GUID-48E514AC-C78B-570F-A96C-389BABA02472"><p>Compression and
       
    18 Decompression are performed iteratively, till the completion of required task. </p> </context>
       
    19 <steps id="GUID-2D2DC7F3-64FA-5C96-95DE-615650E10160">
       
    20 <step id="GUID-C384EAE0-B1EE-5098-A557-1231D35F8A2A"><cmd/>
       
    21 <info>Input the source file and the name of the target gzip file to an instance
       
    22 of the <xref href="GUID-417AB4E0-FF07-34CB-A4A8-CEF31C48A162.dita"><apiname>CEZFileToGZip</apiname></xref> class. </info>
       
    23 </step>
       
    24 <step id="GUID-2A30A687-A777-5790-8145-5AE956F35FFC"><cmd/>
       
    25 <info> <xref href="GUID-417AB4E0-FF07-34CB-A4A8-CEF31C48A162.dita#GUID-417AB4E0-FF07-34CB-A4A8-CEF31C48A162/GUID-4E51D7C5-C624-3F27-A5CD-01E92F96F72B"><apiname>CEZFileToGZip::DeflateL()</apiname></xref> is used to compress the
       
    26 file. </info>
       
    27 </step>
       
    28 </steps>
       
    29 <example><p>The code below depicts how the source file "input.doc" file is
       
    30 converted to target file "output.gz". </p><codeblock xml:space="preserve">/*
       
    31  * If input and output file names are not specified then it is assumed that 
       
    32  * the file names are contained in a provided .ini file.
       
    33  */
       
    34 
       
    35 void CEZlibEZipTests::DoEZlibGZipDeflateL()
       
    36     {
       
    37     
       
    38 
       
    39  RFs iFs;
       
    40  iFS.connect();
       
    41     
       
    42 
       
    43     //Open the source file in read mode
       
    44 _LIT(KInputFileLocation, "c:\\private\\E80000B7\\zip\\input\\input.doc");
       
    45 TFileName inputFile(KInputFileLocation);
       
    46 
       
    47     RFile input;
       
    48     err = input.Open(iFS, inputFile, EFileStream | EFileRead | EFileShareExclusive);
       
    49 
       
    50     if(err != KErrNone)
       
    51         {
       
    52         INFO_PRINTF1(KOpenFileError);
       
    53         User::Leave(err);
       
    54         }   
       
    55     
       
    56     
       
    57     //create a target file
       
    58 
       
    59 _LIT(KOutputFileLocation, "c:\\private\\E80000B7\\zip\\input\\output.gz");
       
    60 TFileName outputFile(KOutputFileLocation);
       
    61 
       
    62 
       
    63     
       
    64     CEZFileToGZip *compressor = CEZFileToGZip::NewLC(iFs, outputFile, input);
       
    65 
       
    66     
       
    67     while(compressor-&gt;DeflateL())
       
    68         {       
       
    69         }   
       
    70 input.Close();
       
    71     iFS.Close();
       
    72         
       
    73     
       
    74     }
       
    75 </codeblock></example>
       
    76 <postreq><p>The decompression of a gzip file can be achieved through the following
       
    77 the steps: </p> <ol id="GUID-A4771CC4-2704-56E3-BBD5-4AB2A58F9468">
       
    78 <li id="GUID-4E130CBF-C626-5CD0-9A83-A2F138B12B68"><p>Pass the file to the
       
    79 constructor of the <xref href="GUID-8DE05785-D058-3855-A11F-7132EB4DE078.dita"><apiname>CEZGZipToFile</apiname></xref> class. </p> </li>
       
    80 <li id="GUID-CB642B02-8A19-5CB9-96E4-80AB7596F6E1"><p> <xref href="GUID-8DE05785-D058-3855-A11F-7132EB4DE078.dita#GUID-8DE05785-D058-3855-A11F-7132EB4DE078/GUID-4A30D99E-EC51-359F-90B5-9CFA3841A538"><apiname>CEZGZipToFile::InflateL()</apiname></xref> is
       
    81 called repeatedly to complete the decompression. </p> </li>
       
    82 </ol> <p>The code below depicts how "output.gz" is decompressed to "input.doc". </p> <codeblock id="GUID-01545D8D-CE1F-5903-9558-CE35D4C3067E" xml:space="preserve">/*
       
    83  *  If  input and output file names are not specified then it is assumed that 
       
    84  * the file names are contained in a provided .ini file.
       
    85  */
       
    86 void CEZlibEZipTests::DoEZlibGZipInflateL()
       
    87     {
       
    88       RFs iFs;
       
    89   iFS.connect();
       
    90     
       
    91 
       
    92     //open output file
       
    93 
       
    94 _LIT(KOutputFile, "c:\\private\\E80000B7\\zip\\input\\input.doc");
       
    95 TFileName outputFile(KOutputFile);
       
    96     RFile output;
       
    97     err = output.Replace(iFs, outputFile, EFileStream | EFileWrite | EFileShareExclusive);
       
    98     if(err != KErrNone)
       
    99         {
       
   100         INFO_PRINTF1(KCreateFileError);
       
   101         User::Leave(err);
       
   102         }    
       
   103         
       
   104 
       
   105 //input file
       
   106 
       
   107 
       
   108 _LIT(KInputFileLocation, "c:\\private\\E80000B7\\zip\\input\\output.gz");
       
   109 TFileName inputFile(KInputFileLocation);
       
   110 
       
   111     CEZGZipToFile *decompressor = CEZGZipToFile::NewLC(iFs, inputFile, output);
       
   112 
       
   113         while(decompressor-&gt;InflateL())
       
   114         {        
       
   115         }    
       
   116 
       
   117         output.Close();
       
   118     iFS.Close();
       
   119     ;
       
   120     }</codeblock> </postreq>
       
   121 </taskbody></task>