crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianImageLib/ROFS/Content/Types/SIContentROFSCode.cs
changeset 0 818e61de6cd1
equal deleted inserted replaced
-1:000000000000 0:818e61de6cd1
       
     1 /*
       
     2 * Copyright (c) 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 "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 using System;
       
    18 using System.Collections.Generic;
       
    19 using System.Text;
       
    20 using System.IO;
       
    21 using SymbianUtils;
       
    22 using SymbianUtils.Tracer;
       
    23 using SymbianUtils.Streams;
       
    24 using SymbianStructuresLib.Uids;
       
    25 using SymbianStructuresLib.Compression.Common;
       
    26 using SymbianImageLib.Common.Content;
       
    27 using SymbianImageLib.Common.Image;
       
    28 using SymbianImageLib.Common.Streams;
       
    29 using SymbianImageLib.E32Image.Image;
       
    30 using SymbianImageLib.E32Image.Content;
       
    31 using SymbianImageLib.E32Image.Header;
       
    32 using SymbianImageLib.ROFS.Image;
       
    33 
       
    34 namespace SymbianImageLib.ROFS.Content
       
    35 {
       
    36     public class SIContentROFSCode : SIContent
       
    37     {
       
    38         #region Constructors
       
    39         internal SIContentROFSCode( SIROFS aImage, string aName, uint aSize, long aPosition )
       
    40             : base( aImage )
       
    41         {
       
    42             // We need to give the E32Image access to the underlying ROFS image stream, but we don't
       
    43             // want to transfer ownership - ownership remains entirely with the SymbianImageROFS object.
       
    44             SIStream e32ImageStream = new SIStream( (Stream) ImageStream, SIStream.TOwnershipType.EOwnedExternally );
       
    45             try
       
    46             {
       
    47                 iE32Image = new SymbianImageE32( aName, aSize, aPosition, e32ImageStream, aImage );
       
    48                 if ( iE32Image.Count == 0 )
       
    49                 {
       
    50                     throw new Exception( "Invalid E32Image file" );
       
    51                 }
       
    52             }
       
    53             catch ( Exception e )
       
    54             {
       
    55                 e32ImageStream.Close();
       
    56                 throw e;
       
    57             }
       
    58         }
       
    59         #endregion
       
    60 
       
    61         #region From SymbianImageContentFile
       
    62         public override TSymbianCompressionType CompressionType
       
    63         {
       
    64             get { return iE32Image.CompressionType; }
       
    65         }
       
    66 
       
    67         public override uint ProvideDataUInt32( uint aAddress )
       
    68         {
       
    69             uint ret = E32ImageContent.ProvideDataUInt32( aAddress );
       
    70             return ret;
       
    71         }
       
    72 
       
    73         public override ushort ProvideDataUInt16( uint aAddress )
       
    74         {
       
    75             ushort ret = E32ImageContent.ProvideDataUInt16( aAddress );
       
    76             return ret;
       
    77         }
       
    78 
       
    79         public override string FileName
       
    80         {
       
    81             get { return E32ImageContent.FileName; }
       
    82         }
       
    83 
       
    84         public override uint FileSize
       
    85         {
       
    86             get { return E32ImageContent.FileSize; }
       
    87         }
       
    88 
       
    89         public override uint ContentSize
       
    90         {
       
    91             get
       
    92             {
       
    93                 uint ret = E32ImageContent.ContentSize;
       
    94                 return ret;
       
    95             }
       
    96         }
       
    97 
       
    98         public override TCheckedUid Uid
       
    99         {
       
   100             get { return E32ImageContent.Uid; }
       
   101         }
       
   102 
       
   103         public override byte[] GetAllData()
       
   104         {
       
   105             return E32ImageContent.GetAllData();
       
   106         }
       
   107 
       
   108         protected override void DoDecompress()
       
   109         {
       
   110             // We can prepare the content synchronously because we're either running
       
   111             // in a separate thread (async) or supposed to be performing the operation
       
   112             // synchronously in any case.
       
   113             SIContentE32Image content = E32ImageContent;
       
   114             content.PrepareContent( TSynchronicity.ESynchronous );
       
   115         }
       
   116 
       
   117         protected override void OnRelocationAddressChanged( uint aOld, uint aNew )
       
   118         {
       
   119             // Cascade the relocation change to the E32Image
       
   120             E32ImageContent.RelocationAddress = aNew;
       
   121         }
       
   122 
       
   123         protected override bool GetIsContentPrepared()
       
   124         {
       
   125             return E32ImageContent.IsContentPrepared;
       
   126         }
       
   127         #endregion
       
   128 
       
   129         #region From DisposableObject
       
   130         protected override void CleanupManagedResources()
       
   131         {
       
   132             try
       
   133             {
       
   134                 base.CleanupManagedResources();
       
   135             }
       
   136             finally
       
   137             {
       
   138                 iE32Image.Dispose();
       
   139             }
       
   140         }
       
   141         #endregion
       
   142 
       
   143         #region Properties
       
   144         internal SIContentE32Image E32ImageContent
       
   145         {
       
   146             get { return iE32Image[ 0 ] as SIContentE32Image; }
       
   147         }
       
   148         #endregion
       
   149 
       
   150         #region Data members
       
   151         private readonly SymbianImageE32 iE32Image;
       
   152         #endregion
       
   153     }
       
   154 }