userlibandfileserver/fileserver/sfile/sf_decomp.cpp
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 1995-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 the License "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 // f32\sfile\sf_decomp.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "sf_deflate.h"
       
    19 #include <f32file.h>
       
    20 #include <e32svr.h>
       
    21 
       
    22  
       
    23 TFileInput::TFileInput(RFile& aFile)
       
    24 	:iFile(aFile),iReadBuf(iBuf1),iPtr(iBuf1,KBufSize)
       
    25 	{
       
    26 	// issue first read
       
    27 	aFile.Read(iPtr,iStat);
       
    28 	}
       
    29 
       
    30 void TFileInput::Cancel()
       
    31 	{
       
    32 	// absorb signal if outstanding request
       
    33 	if (iReadBuf)
       
    34 		User::WaitForRequest(iStat);
       
    35 	}
       
    36 
       
    37 void TFileInput::UnderflowL()
       
    38 	{
       
    39 	TUint8* b=iReadBuf;
       
    40 	ASSERT(b!=NULL);
       
    41 	User::WaitForRequest(iStat);
       
    42 	iReadBuf=0;
       
    43 	User::LeaveIfError(iStat.Int());
       
    44 	if(iPtr.Length()==0)
       
    45 		User::Leave(KErrCorrupt);
       
    46 	Set(b,iPtr.Length()*8);
       
    47 	// start reading to the next buffer
       
    48 	b = b==iBuf1 ? iBuf2 : iBuf1;
       
    49 	iPtr.Set(b,0,KBufSize);
       
    50 	iFile.Read(iPtr,iStat);
       
    51 	iReadBuf=b;
       
    52 	}