installationservices/swi/source/sisfile/sisdataunit.cpp
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * Definition of the Swi::Sis::CDataUnit
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include "sisdataunit.h"
       
    21 #include "sisfiledata.h"
       
    22 
       
    23 using namespace Swi::Sis;
       
    24 
       
    25 /*static*/ CDataUnit* CDataUnit::NewLC(MSisDataProvider& aDataProvider, TInt64& aBytesRead, TReadTypeBehaviour aTypeReadBehaviour)
       
    26 	{
       
    27 	CDataUnit* self = new(ELeave) CDataUnit();
       
    28 	CleanupStack::PushL(self);
       
    29 	self->ConstructL(aDataProvider, aBytesRead, aTypeReadBehaviour);
       
    30 	return self;
       
    31 	}
       
    32 
       
    33 /*static*/ CDataUnit* CDataUnit::NewL(MSisDataProvider& aDataProvider, TInt64& aBytesRead, TReadTypeBehaviour aTypeReadBehaviour)
       
    34 	{
       
    35 	CDataUnit* self = NewLC(aDataProvider, aBytesRead, aTypeReadBehaviour);
       
    36 	CleanupStack::Pop(self);
       
    37 	return self;
       
    38 	}
       
    39 
       
    40 CDataUnit::CDataUnit()
       
    41 	{
       
    42 	}
       
    43 
       
    44 CDataUnit::~CDataUnit()
       
    45 	{
       
    46 	iCompressedFiles.ResetAndDestroy();
       
    47 	}
       
    48 
       
    49 void CDataUnit::ConstructL(MSisDataProvider& aDataProvider, TInt64& aBytesRead, TReadTypeBehaviour aTypeReadBehaviour)
       
    50 	{
       
    51 	
       
    52 	TInt64 fieldOffset = aBytesRead;
       
    53 	
       
    54 	CField::ConstructL(aDataProvider, EFieldTypeDataUnit, aBytesRead, aTypeReadBehaviour);
       
    55 
       
    56 	ReadMemberArrayL(aDataProvider, iCompressedFiles, EFieldTypeFileData, aBytesRead, EReadType);
       
    57 	CField::SkipUnknownFieldsL(aDataProvider, aBytesRead - fieldOffset, aBytesRead, aTypeReadBehaviour);
       
    58 	CField::EnsureAlignedL(aDataProvider, aBytesRead - fieldOffset, aBytesRead, aTypeReadBehaviour);
       
    59 	}
       
    60 	
       
    61 void CDataUnit::ExtractDataFileL(RFile& aFile, TInt aFileIndex)
       
    62 	{	
       
    63 	if ((aFileIndex < 0) || (aFileIndex >= iCompressedFiles.Count()))
       
    64 		{
       
    65 		User::Leave(KErrCorrupt);
       
    66 		}
       
    67 	
       
    68 	iCompressedFiles[aFileIndex]->ExtractDataFieldL(aFile);
       
    69 	}
       
    70 
       
    71 void CDataUnit::ExtractDataFileL(RFile& aFile, TInt aFileIndex, TInt64 aLength)
       
    72 	{
       
    73 	if ((aFileIndex < 0) || (aFileIndex >= iCompressedFiles.Count()))
       
    74 		{
       
    75 		User::Leave(KErrCorrupt);
       
    76 		}
       
    77 	iCompressedFiles[aFileIndex]->ExtractDataFieldL(aFile, aLength);
       
    78 	}