compressionlibs/ziplib/test/oldezlib/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 "OldEZstream.h"
       
    17 using namespace TOLDEZLIB;
       
    18 
       
    19 CEZZStream::CEZZStream() : iOutputPointer(NULL), iOutputBufferLength(0)
       
    20 	{
       
    21 
       
    22 	}
       
    23 
       
    24 /**
       
    25 Set the stream's input buffer
       
    26 
       
    27 @param aInputData the input buffer for this stream
       
    28 */
       
    29 EXPORT_C void CEZZStream::SetInput(const TDesC8& aInputData)
       
    30 	{	
       
    31 	iStream.avail_in = aInputData.Size();
       
    32 	iStream.next_in = STATIC_CAST(Bytef* ,CONST_CAST(TUint8 *,aInputData.Ptr()));
       
    33 	}
       
    34 
       
    35 /**
       
    36 Set the stream's output buffer
       
    37 
       
    38 @param aOutputData the output buffer for this stream
       
    39 */
       
    40 EXPORT_C void CEZZStream::SetOutput(TDes8& aOutputData)
       
    41 	{
       
    42 	iOutputPointer = STATIC_CAST(Bytef* ,CONST_CAST(TUint8 *,aOutputData.Ptr()));
       
    43 	iOutputBufferLength = aOutputData.MaxSize();
       
    44 	iStream.avail_out = iOutputBufferLength;
       
    45 	iStream.next_out = iOutputPointer;
       
    46 	}
       
    47 
       
    48 /**
       
    49 Return the progress of the current operation - that is the percentage of bytes written / read
       
    50 
       
    51 @param aTotalLength the total number of bytes to read / write
       
    52 @return the progress as a percentage - the number of bytes written / read out of the total target
       
    53 */
       
    54 EXPORT_C TInt CEZZStream::Progress(TInt aTotalLength) const
       
    55 	{
       
    56 	return (aTotalLength == 0) ? 100 : ((iStream.total_in  * 100) / aTotalLength);
       
    57 	}
       
    58 
       
    59 /**
       
    60 Return the total number of bytes output so far
       
    61 
       
    62 @return the total number of bytes output so far
       
    63 */
       
    64 EXPORT_C TInt CEZZStream::TotalOut() const
       
    65 	{
       
    66 	return iStream.total_out;
       
    67 	}
       
    68 
       
    69 /**
       
    70 Return the total number of input bytes read so far
       
    71 
       
    72 @return the total number of input bytes read so far
       
    73 */
       
    74 EXPORT_C TInt CEZZStream::TotalIn() const
       
    75 	{
       
    76 	return iStream.total_in;
       
    77 	}
       
    78 
       
    79 /**
       
    80 Return the value of the uncompressed data
       
    81 
       
    82 @return the value of the uncompressed data
       
    83 */
       
    84 EXPORT_C TInt32 CEZZStream::Adler32() const
       
    85 	{
       
    86 	return iStream.adler;
       
    87 	}
       
    88 
       
    89 /**
       
    90 Return the number of bytes available at the next input byte
       
    91 
       
    92 @return the number of bytes available at the next input byte
       
    93 */
       
    94 EXPORT_C TInt CEZZStream::AvailIn() const
       
    95 	{
       
    96 	return iStream.avail_in;
       
    97 	}
       
    98 
       
    99 /**
       
   100 Return the remaining free space at next output byte target
       
   101 
       
   102 @return the remaining free space at next output byte target
       
   103 */
       
   104 EXPORT_C TInt CEZZStream::AvailOut() const
       
   105 	{
       
   106 	return iStream.avail_out;
       
   107 	}
       
   108 
       
   109 /**
       
   110 Return a decriptor pointer to the output buffer
       
   111 
       
   112 @return a decriptor pointer to the output buffer
       
   113 */
       
   114 EXPORT_C TPtrC8 CEZZStream::OutputDescriptor() const
       
   115 	{
       
   116 	return TPtrC8(iOutputPointer,iOutputBufferLength - iStream.avail_out);
       
   117 	}
       
   118