commands/chkdeps/sf_pgcompr.h
changeset 0 7f656887cf89
equal deleted inserted replaced
-1:000000000000 0:7f656887cf89
       
     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 // Accenture - minor tweaks to build in to fshell chkdeps command
       
    13 //
       
    14 // Description:
       
    15 // f32\sfile\sf_pgcompr.h
       
    16 // 
       
    17 //
       
    18 
       
    19 #ifndef __SF_PGCOMPR_H__
       
    20 #define __SF_PGCOMPR_H__
       
    21 
       
    22 #include <e32base.h>
       
    23 #include<f32file.h>
       
    24 //#include "sf_std.h"
       
    25 #include <f32image.h>
       
    26 //#include "sf_image.h"
       
    27 #include <e32uid.h>
       
    28 #include <e32rom.h>
       
    29 //#include "sf_cache.h"
       
    30 
       
    31 
       
    32 const TUint KBytePairPageSize = 4096;
       
    33 
       
    34 // Buffer sized for at least 8 compressed pages - a noncompressible page is one byte larger
       
    35 const TUint KReadNumberOfPages = 8;
       
    36 const TUint KPagesBufferSize = (KBytePairPageSize + 1) * KReadNumberOfPages;
       
    37 
       
    38 typedef TUint8* (*TMemoryMoveFunction)(TAny* aTrg,const TAny* aSrc,TInt aLength); 
       
    39 
       
    40 struct IndexTableHeader
       
    41 	{
       
    42 	TInt	iSizeOfData;					// Includes the index and compressed pages
       
    43 	TInt	iDecompressedSize;
       
    44 	TUint16	iNumberOfPages;
       
    45 	};
       
    46 
       
    47 // sizeof(IndexTableHeader) returns the wrong value due to rounding/padding, so calculate it
       
    48 const TUint KIndexTableHeaderSize = sizeof(TInt) + sizeof(TInt) + sizeof(TUint16);
       
    49 
       
    50 NONSHARABLE_CLASS(CBytePairReader) : public CBase
       
    51 	{
       
    52 public:
       
    53 	static CBytePairReader* NewLC(TUint8* aBuffer, TUint32 aLength);
       
    54 	CBytePairReader(TUint8* aBuffer, TUint32 aLength);
       
    55 
       
    56 	virtual TUint DecompressPagesL(TUint8* aTarget, TInt aLength, TMemoryMoveFunction aMemMoveFn);
       
    57 	void GetPageOffsetsL(TInt32 aInitialOffset, TInt& aPageCount, TInt32*& aPageStarts);
       
    58 	TUint GetPageL(TUint aPageNum, TUint8* aTarget, TInt aLength, TMemoryMoveFunction aMemMoveFn);		
       
    59 	virtual void SeekForwardL(TUint aBytes);
       
    60 
       
    61 protected:
       
    62 	virtual void ReadInTableL();
       
    63 	void ReleaseTable();
       
    64 
       
    65 	IndexTableHeader iHeader;
       
    66 	TUint16* iIndexTable;
       
    67 	TUint8* iNextPage;
       
    68 	TUint iBytesLeft;
       
    69 	TUint8 iPageBuf[KBytePairPageSize];
       
    70 	};
       
    71 
       
    72 NONSHARABLE_CLASS(CBytePairFileReader) : public CBytePairReader
       
    73 	{
       
    74 public:
       
    75 	static CBytePairFileReader* NewLC(RFile& aFile);
       
    76 	CBytePairFileReader(RFile& aFile);
       
    77 	~CBytePairFileReader();
       
    78 
       
    79 	virtual TUint DecompressPagesL(TUint8* aTarget, TInt aLength, TMemoryMoveFunction aMemMovefn);
       
    80 	virtual void SeekForwardL(TUint aBytes);
       
    81 
       
    82 protected:
       
    83 	virtual void ReadInTableL();
       
    84 
       
    85 	RFile& iFile;
       
    86 	TUint8 iBuffer[KPagesBufferSize];
       
    87 	};
       
    88 
       
    89 #endif // __SF_PGCOMPR_H__