reszip/inc/rescomp.h
changeset 0 f58d6ec98e88
child 9 7c80ebddf816
equal deleted inserted replaced
-1:000000000000 0:f58d6ec98e88
       
     1 /*
       
     2 * Copyright (c) 1997-1999 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 
       
    18 
       
    19 
       
    20 #if !defined(__RESCOMP_H__)
       
    21 #define __RESCOMP_H__
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <f32file.h>
       
    25 #include <s32file.h>
       
    26 
       
    27 class CDictArray;
       
    28 class CResEntry;
       
    29 
       
    30 class TBitWriter
       
    31 	{
       
    32 public:
       
    33 	TBitWriter(RWriteStream& aStream);
       
    34 	void WriteL(TInt aValue, TInt aBits);
       
    35 	void FlushL();
       
    36 private:
       
    37 	RWriteStream& iStream;
       
    38 	TInt iValue;
       
    39 	TInt iBitsWritten;
       
    40 	};
       
    41 
       
    42 class CResComp : public CBase
       
    43 	{
       
    44 public:
       
    45 	CResComp(CConsoleBase* aConsole);
       
    46 	~CResComp();
       
    47 	void LoadFileL(RFs& aFs, const TDesC& aFileName);
       
    48 	void CompressL();
       
    49 	void WriteFileL(RFs& aFs, const TDesC& aName);
       
    50 	TPtrC8 Resource(TInt aRes);
       
    51 	TInt FindInResources(TDesC8& aBuf, TInt aMax);
       
    52 	TInt OriginalFileSize();
       
    53 	TInt CompressedSize();
       
    54 	void DisplayStats();
       
    55 	TInt ResourceSize();
       
    56 	TBool IsValid();
       
    57 private:
       
    58 	void LoadBAFLCompressedFileL(RFs& aFs, const TDesC& aName);
       
    59 	void LoadUnCompressedFileL(RFs& aFs, const TDesC& aName);
       
    60 	TBool FileIsBAFLCompressedL(RFs& aFs, const TDesC& aName);
       
    61 
       
    62 	void OptimizeDict();
       
    63 	void FindEmbeddedDict(TDesC8& aMatch, TInt aStart);
       
    64 	void WriteHeaderL(RWriteStream& aStream);
       
    65 	void WriteDictionaryL(RWriteStream& aStream);
       
    66 	void WriteDictionaryHeaderL(RWriteStream& aStream);
       
    67 	void WriteDictionaryIndexL(RWriteStream& aStream);
       
    68 	void WriteDictionaryDataL(RWriteStream& aStream);
       
    69 	void WriteResourceL(RWriteStream& aStream);
       
    70 	void WriteResourceIndexL(RWriteStream& aStream);
       
    71 	void WriteResourceDataL(RWriteStream& aStream);
       
    72 	TInt CompressResourcesL(TInt aMaxDictEntries);
       
    73 	TInt AttemptCompressionL(TInt aMaxDictEntries);
       
    74 	void CheckForLongDataStringsL();
       
    75 private:
       
    76 	CConsoleBase* iConsole;
       
    77 	TUint8* iResData;
       
    78 	CDictArray* iDict;
       
    79 	TUint16* iResIndex;
       
    80 	CArrayPtrFlat<CResEntry>* iResArray;
       
    81 	TInt iResources;
       
    82 	TInt iFileLength;
       
    83 	TInt iCompressedSize;
       
    84 	TInt iLargestResourceSize;
       
    85 	TInt iMaxEntries;
       
    86 	TInt iBitsForDict;
       
    87 	TInt iBestCompression;
       
    88 	TInt iBestSize;
       
    89 	TInt iOriginalCompressedSize;
       
    90 public:
       
    91 	TBuf<80> iConOutput;
       
    92 	};
       
    93 
       
    94 
       
    95 #endif