crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianImageLib/ROFS/Content/Types/SIContentROFSData.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.ROFS.Image;
       
    30 
       
    31 namespace SymbianImageLib.ROFS.Content
       
    32 {
       
    33     public class SIContentROFSData : SIContent
       
    34     {
       
    35         #region Constructors
       
    36         internal SIContentROFSData( SIROFS aImage, string aName, uint aSize, long aPosition, TCheckedUid aUids )
       
    37             : base( aImage )
       
    38         {
       
    39             iFileName = aName;
       
    40             iUids = aUids;
       
    41             iFileSize = aSize;
       
    42             iPosition = aPosition;
       
    43         }
       
    44         #endregion
       
    45 
       
    46         #region From SymbianImageContentFile
       
    47         public override TSymbianCompressionType CompressionType
       
    48         {
       
    49             get
       
    50             {
       
    51                 return TSymbianCompressionType.ENone;
       
    52             }
       
    53         }
       
    54 
       
    55         public override string FileName
       
    56         {
       
    57             get { return iFileName; }
       
    58         }
       
    59 
       
    60         public override uint FileSize
       
    61         {
       
    62             get { return iFileSize; }
       
    63         }
       
    64 
       
    65         public override uint ContentSize
       
    66         {
       
    67             get { return FileSize; }
       
    68         }
       
    69 
       
    70         public override TCheckedUid Uid
       
    71         {
       
    72             get { return iUids; }
       
    73         }
       
    74 
       
    75         public override byte[] GetAllData()
       
    76         {
       
    77             byte[] ret = null;
       
    78             //
       
    79             using ( SymbianStreamReaderLE reader = SymbianStreamReaderLE.New( (Stream) base.ImageStream, SymbianStreamReaderLE.TCloseOperation.EResetPosition ) )
       
    80             {
       
    81                 reader.Position = iPosition;
       
    82                 ret = reader.ReadBytes( (int) iFileSize );
       
    83             }
       
    84             //
       
    85             return ret;
       
    86         }
       
    87 
       
    88         public override bool IsCode
       
    89         {
       
    90             get { return false; }
       
    91         }
       
    92 
       
    93         protected override uint DoProvideDataUInt32( uint aTranslatedAddress )
       
    94         {
       
    95             using ( SymbianStreamReaderLE reader = Image.Stream.CreateReader( SymbianStreamReaderLE.TCloseOperation.ENone ) )
       
    96             {
       
    97                 reader.Seek( aTranslatedAddress );
       
    98                 uint ret = reader.ReadUInt32();
       
    99                 return ret;
       
   100             }
       
   101         }
       
   102 
       
   103         protected override ushort DoProvideDataUInt16( uint aTranslatedAddress )
       
   104         {
       
   105             using ( SymbianStreamReaderLE reader = Image.Stream.CreateReader( SymbianStreamReaderLE.TCloseOperation.ENone ) )
       
   106             {
       
   107                 reader.Seek( aTranslatedAddress );
       
   108                 ushort ret = reader.ReadUInt16();
       
   109                 return ret;
       
   110             }
       
   111         }
       
   112 
       
   113         protected override bool GetIsContentPrepared()
       
   114         {
       
   115             // We just read straight from the file
       
   116             return true;
       
   117         }
       
   118         #endregion
       
   119 
       
   120         #region Properties
       
   121         public long Position
       
   122         {
       
   123             get { return iPosition; }
       
   124         }
       
   125         #endregion
       
   126 
       
   127         #region Data members
       
   128         private readonly string iFileName;
       
   129         private readonly uint iFileSize;
       
   130         private readonly long iPosition;
       
   131         private readonly TCheckedUid iUids;
       
   132         #endregion
       
   133     }
       
   134 }