imgtools/imgcheck/libimgutils/src/rofsimage.cpp
changeset 0 044383f39525
child 590 360bd6b35136
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 /*
       
     2 * Copyright (c) 2007-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 *
       
    16 */
       
    17 
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalComponent
       
    22  @released
       
    23 */
       
    24 
       
    25 #include "typedefs.h"
       
    26 #include "rofsimage.h"
       
    27 
       
    28 /** 
       
    29 Constructor.
       
    30 
       
    31 @internalComponent
       
    32 @released
       
    33 
       
    34 @param aReader - image reader pointer
       
    35 */
       
    36 RofsImage::RofsImage(RCoreImageReader *aReader)
       
    37 : CCoreImage(aReader) ,
       
    38 iRofsHeader(0), iRofsExtnHeader(0),iAdjustment(0), 
       
    39 iImageType((RCoreImageReader::TImageType)0)
       
    40 {
       
    41 }
       
    42 
       
    43 /** 
       
    44 Destructor deletes iRofsHeader and iRofsExtnHeader.
       
    45 
       
    46 @internalComponent
       
    47 @released
       
    48 
       
    49 @param aReader - image reader pointer
       
    50 */
       
    51 RofsImage::~RofsImage()
       
    52 {
       
    53 	DELETE(iRofsHeader);
       
    54 	DELETE(iRofsExtnHeader);
       
    55 }
       
    56 
       
    57 /** 
       
    58 Function responsible to read the ROFS image and to construct the tree for the 
       
    59 elements available in Directory section.
       
    60 
       
    61 @internalComponent
       
    62 @released
       
    63 
       
    64 @return - returns the error code
       
    65 */
       
    66 TInt RofsImage::ProcessImage()
       
    67 {
       
    68 	int result = CreateRootDir();
       
    69 	if (result == KErrNone)
       
    70 	{
       
    71 		if (iReader->Open())
       
    72 		{
       
    73 			iImageType = iReader->ReadImageType();
       
    74 			if (iImageType == RCoreImageReader::E_ROFS)
       
    75 			{
       
    76 				iRofsHeader = new TRofsHeader;
       
    77 				result = iReader->ReadCoreHeader(*iRofsHeader);
       
    78 				if (result != KErrNone)
       
    79 					return result;
       
    80 				
       
    81 				SaveDirInfo(*iRofsHeader);
       
    82 				result = ProcessDirectory(0);
       
    83 			}
       
    84 			else if (iImageType == RCoreImageReader::E_ROFX)
       
    85 			{
       
    86 				iRofsExtnHeader = new TExtensionRofsHeader ;
       
    87 				result = iReader->ReadExtensionHeader(*iRofsExtnHeader);
       
    88 				if(result != KErrNone)
       
    89 					return result;
       
    90 
       
    91 				long filePos = iReader->FilePosition();
       
    92 				iAdjustment = iRofsExtnHeader->iDirTreeOffset - filePos;
       
    93 
       
    94 				SaveDirInfo(*iRofsExtnHeader);
       
    95 				result = ProcessDirectory(iAdjustment);
       
    96 			}
       
    97 			else
       
    98 			{
       
    99 				result = KErrNotSupported;
       
   100 			}
       
   101 		}
       
   102 		else
       
   103 		{
       
   104 			result = KErrGeneral;
       
   105 		}
       
   106 	}
       
   107 	return result;
       
   108 }