compressionlibs/ziplib/src/ezlib/zstream.cpp
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <ezstream.h>
       
    17 
       
    18 CEZZStream::CEZZStream() : iOutputPointer(NULL), iOutputBufferLength(0)
       
    19 	{
       
    20 
       
    21 	}
       
    22 
       
    23 /**
       
    24 Set the stream's input buffer
       
    25 
       
    26 @param aInputData the input buffer for this stream
       
    27 */
       
    28 EXPORT_C void CEZZStream::SetInput(const TDesC8& aInputData)
       
    29 	{	
       
    30 	iStream.avail_in = aInputData.Size();
       
    31 	iStream.next_in = STATIC_CAST(Bytef* ,CONST_CAST(TUint8 *,aInputData.Ptr()));
       
    32 	}
       
    33 
       
    34 /**
       
    35 Set the stream's output buffer
       
    36 
       
    37 @param aOutputData the output buffer for this stream
       
    38 */
       
    39 EXPORT_C void CEZZStream::SetOutput(TDes8& aOutputData)
       
    40 	{
       
    41 	iOutputPointer = STATIC_CAST(Bytef* ,CONST_CAST(TUint8 *,aOutputData.Ptr()));
       
    42 	iOutputBufferLength = aOutputData.MaxSize();
       
    43 	iStream.avail_out = iOutputBufferLength;
       
    44 	iStream.next_out = iOutputPointer;
       
    45 	}
       
    46 
       
    47 /**
       
    48 Return the progress of the current operation - that is the percentage of bytes written / read
       
    49 
       
    50 @param aTotalLength the total number of bytes to read / write
       
    51 @return the progress as a percentage - the number of bytes written / read out of the total target
       
    52 */
       
    53 EXPORT_C TInt CEZZStream::Progress(TInt aTotalLength) const
       
    54 	{
       
    55 	return (aTotalLength == 0) ? 100 : ((iStream.total_in  * 100) / aTotalLength);
       
    56 	}
       
    57 
       
    58 /**
       
    59 Return the total number of bytes output so far
       
    60 
       
    61 @return the total number of bytes output so far
       
    62 */
       
    63 EXPORT_C TInt CEZZStream::TotalOut() const
       
    64 	{
       
    65 	return iStream.total_out;
       
    66 	}
       
    67 
       
    68 /**
       
    69 Return the total number of input bytes read so far
       
    70 
       
    71 @return the total number of input bytes read so far
       
    72 */
       
    73 EXPORT_C TInt CEZZStream::TotalIn() const
       
    74 	{
       
    75 	return iStream.total_in;
       
    76 	}
       
    77 
       
    78 /**
       
    79 Return the value of the uncompressed data
       
    80 
       
    81 @return the value of the uncompressed data
       
    82 */
       
    83 EXPORT_C TInt32 CEZZStream::Adler32() const
       
    84 	{
       
    85 	return iStream.adler;
       
    86 	}
       
    87 
       
    88 /**
       
    89 Return the number of bytes available at the next input byte
       
    90 
       
    91 @return the number of bytes available at the next input byte
       
    92 */
       
    93 EXPORT_C TInt CEZZStream::AvailIn() const
       
    94 	{
       
    95 	return iStream.avail_in;
       
    96 	}
       
    97 
       
    98 /**
       
    99 Return the remaining free space at next output byte target
       
   100 
       
   101 @return the remaining free space at next output byte target
       
   102 */
       
   103 EXPORT_C TInt CEZZStream::AvailOut() const
       
   104 	{
       
   105 	return iStream.avail_out;
       
   106 	}
       
   107 
       
   108 /**
       
   109 Return a decriptor pointer to the output buffer
       
   110 
       
   111 @return a decriptor pointer to the output buffer
       
   112 */
       
   113 EXPORT_C TPtrC8 CEZZStream::OutputDescriptor() const
       
   114 	{
       
   115 	return TPtrC8(iOutputPointer,iOutputBufferLength - iStream.avail_out);
       
   116 	}
       
   117