RResourceFileImpl Class Reference

class RResourceFileImpl

Accesses a resource file and reads the resource data into a buffer.

It is the implementation class for RResourceFile and CResourceFile classes.

Because of BC reasons, the size of RResourceFileImpl must be the same as the size of RResourceFile class.

It is expected that all resources deallocation must be done in Close() method. (BC reasons - RResourceFile reserves enough space for the RResourceFileImpl instance and uses placement new operator to create it. But RResourceFile doesn't have a destructor, so there is no predictable way how the RResourceFileImpl destructor might be called, even if the class has user defined destructor).

Expected behaviour when assignment operator or copy constructor is called: The class doesn't have assignment operator and copy constructor, so the compiler generated ones will be used. The heap buffers used by the source class instance will be shared with the destination class instance.

Methods panic/leave behaviour: "L" methods panics/leave behaviour depends on iAssertObj member (iExtra data member actually). If iAssertObj internal state is TBaAssert::EPanic - "L" methods will panic, otherwise they will leave if something goes wrong.

RResourceFile CResourceFile

Public Member Functions
RResourceFileImpl()
~RResourceFileImpl()
HBufC8 *AllocReadLC(TInt)
voidClose()
voidConfirmSignatureL(TInt)
voidConfirmSignatureL()
TInt Offset()
voidOpenL(RFs &, const TDesC &, const TBaAssert &, TUint, TInt)
voidOpenL(const TDesC8 &, const TBaAssert &)
TBool OwnsResourceIdL(TInt)
voidReadL(TDes8 &, TInt)
TInt SignatureL()
TUidType UidType()
Private Member Functions
voidAppendDecompressedUnicodeL(TDes8 &, const TDesC8 &)
voidAppendDictionaryCompressionBitStreamL(RArray< RDictionaryCompressionBitStream > &, TUint, const SDictionaryCompressionData &, TInt, TInt, TInt)
HBufC8 *DecompressUnicodeL(const TDesC8 &, TInt)
HBufC8 *DictionaryDecompressedResourceDataLC(TInt, TUint, const SDictionaryCompressionData &, const TDesC16 &)
SSigRecord FirstRecordL()
TInt LittleEndianTwoByteIntegerL(const TDesC8 &, TInt)
voidReadHeaderAndResourceIndexL()
voidReadL(TInt, TDes8 &, TInt)
voidReadL(TUint, TInt, TDes8 &, TInt)
Private Member Enumerations
enumanonymous {
EFlagIsRomFile = 0x80000000, EFlagPotentiallyContainsCompressedUnicode = 0x40000000, EFlagDictionaryCompressed = 0x20000000, EFlagThirdUidIsOffset = 0x10000000, EFlagGenerate_RSS_SIGNATURE_ForFirstUserResource = 0x08000000, EFlagFirstResourceIsGeneratedBitArrayOfResourcesContainingCompressedUnicode = 0x04000000, EFlagCalypsoFileFormat = 0x02000000, EFlagIsBufferRscFile = 0x01000000, EAllFlags = 0xff000000
}
enumanonymous { EOffsetBits = 0xfffff000, EIdBits = 0x00000fff }
Private Attributes
TExtra *iExtra
TAny *iFile
TUint iFlagsAndNumberOfResources
HBufC16 *iIndex
TInt iOffset
TInt iSizeOfLargestResourceWhenCompletelyUncompressed

Constructor & Destructor Documentation

RResourceFileImpl()

RResourceFileImpl()

~RResourceFileImpl()

~RResourceFileImpl()

Member Functions Documentation

AllocReadLC(TInt)

HBufC8 *AllocReadLC(TIntaResourceId)const

Reads a resource into a heap descriptor, returns a pointer to that descriptor and pushes the pointer onto the cleanup stack.

A heap descriptor of appropriate length is allocated for the resource. Ownership of the heap descriptor passes to the caller who must destroy it and pop its pointer off the cleanup stack when it is no longer needed.The search for the resource uses the following algorithm:A resource id in the range 1 to 4095 is looked up in this resource file. The function leaves if there is no matching resource.If the resource id is greater than 4095, then the most significant 20 bits of the resource id is treated as an offset and the least significant 12 bits is treated as the real resource id. If the offset matches the offset value defined for this file, then the resource is looked up in this resource file using the real resource id (i.e. the least significant 12 bits). If the offset does not match, then the function leaves.Note, do not call this function until a call to ConfirmSignatureL() has completed successfully.

Pre-condition
OpenL() is called.
ConfirmSignatureL()
panic
Some BAFL panic codes, if the file is corrupted.
leave
KErrCorrupt The file is corrupted.
leave
KErrNotFound There is no resource with aResourceId in the file. Some other error codes are possible too. The method could panic or leave depending on the state of iAssertObj member of RResourceFileImpl::TExtra class.

Parameters

TInt aResourceIdThe numeric id of the resource to be read.

AppendDecompressedUnicodeL(TDes8 &, const TDesC8 &)

voidAppendDecompressedUnicodeL(TDes8 &aBuffer,
const TDesC8 &aCompressedUnicode
)const [private]

The method will decomress the unicode data (aCompressedUnicode argument) and append the decompressed data to the end of aBuffer (aBuffer argument).

Pre-condition
OpenL() is called.
panic
Some BAFL panic codes, if the file is corrupted.
leave
KErrCorrupt The file is corrupted. Some other error codes are possible too. The method could panic or leave depending on the state of iAssertObj member of RResourceFileImpl::TExtra class.

Parameters

TDes8 & aBufferDestination buffer.
const TDesC8 & aCompressedUnicodeCompressed unicode buffer.

AppendDictionaryCompressionBitStreamL(RArray< RDictionaryCompressionBitStream > &, TUint, const SDictionaryCompressionData &, TInt, TInt, TInt)

voidAppendDictionaryCompressionBitStreamL(RArray< RDictionaryCompressionBitStream > &aStackOfDictionaryCompressionBitStreams,
TUintaFlags,
const SDictionaryCompressionData &aDictionaryCompressionData,
TIntaStartOfBitData,
TIntaStartOfIndex,
TIntaIndexEntry
)const [private]
Pre-condition
OpenL() is called.
panic
Some BAFL panic codes, if the file is corrupted.
leave
KErrCorrupt The file is corrupted. Some other error codes are possible too. The method could panic or leave depending on the state of iAssertObj member of RResourceFileImpl::TExtra class.

Parameters

RArray< RDictionaryCompressionBitStream > & aStackOfDictionaryCompressionBitStreams
TUint aFlags
const SDictionaryCompressionData & aDictionaryCompressionData
TInt aStartOfBitData
TInt aStartOfIndex
TInt aIndexEntry

Close()

voidClose()

Closes the resource file reader. This function is called after finishing reading all resources.

ConfirmSignatureL(TInt)

voidConfirmSignatureL(TIntaSignature)
Initialises the offset value from the first resource. The function assumes that the first resource in the file consists of two 32-bit integers. The first integer contains the version number and the second is a self-referencing link whose value is the offset for the resources in the file, plus 1.This function must be called before calling Offset(), AllocReadL(), AllocReadLC() or ReadL().
Pre-condition
OpenL() is called.
Offset() AllocReadL() AllocReadLC() ReadL()
panic
Some BAFL panic codes, if the file is corrupted.
leave
KErrCorrupt The file is corrupted. Some other error codes are possible too. The method could panic or leave depending on the state of iAssertObj member of RResourceFileImpl::TExtra class.

Parameters

TInt aSignatureThis argument value is not used by the function.

ConfirmSignatureL()

voidConfirmSignatureL()

Initialises the offset value from the first resource.

The function tests to catch cases where the first resource is not an RSS_SIGNATURE. It assumes that the first resource in the file consists of two 32-bit integers. The first integer contains the version number and the second is a self-referencing link whose value is the offset for the resources in the file, plus 1.This function must be called before calling Offset(), AllocReadL(), AllocReadLC() or ReadL().

Offset() AllocReadL() AllocReadLC() ReadL()
Pre-condition
OpenL() is called.
panic
Some BAFL panic codes, if the file is corrupted.
leave
KErrCorrupt The file is corrupted. Some other error codes are possible too. The method could panic or leave depending on the state of iAssertObj member of RResourceFileImpl::TExtra class.

DecompressUnicodeL(const TDesC8 &, TInt)

HBufC8 *DecompressUnicodeL(const TDesC8 &aDictionaryDecompressedResourceData,
TIntaSizeOfLargestResourceWhenCompletelyUncompressed
)const [private]

The method will decompress the unicode data (aInputResourceData argument), allocate enough memory from the heap for the decompressed data, copy the data there and return a descriptor to the decompressed data.

The method doesn't own the allocated heap memory for the decompressed data. It's a caller responsibility to deallocate the allocated memory.

Pre-condition
OpenL() is called.
panic
Some BAFL panic codes, if the file is corrupted.
leave
KErrCorrupt The file is corrupted.
leave
KErrNoMemory There is not enough memory for the decompressed data. Some other error codes are possible too. The method could panic or leave depending on the state of iAssertObj member of RResourceFileImpl::TExtra class.

Parameters

const TDesC8 & aDictionaryDecompressedResourceDataCompressed data.
TInt aSizeOfLargestResourceWhenCompletelyUncompressedThe size of decomressed data.

DictionaryDecompressedResourceDataLC(TInt, TUint, const SDictionaryCompressionData &, const TDesC16 &)

HBufC8 *DictionaryDecompressedResourceDataLC(TIntaResourceIndex,
TUintaFlags,
const SDictionaryCompressionData &aDictionaryCompressionData,
const TDesC16 &aIndex
)const [private]
Pre-condition
OpenL() is called.
panic
Some BAFL panic codes, if the file is corrupted.
leave
KErrCorrupt The file is corrupted.
leave
KErrNoMemory There is not enough memory for the decompressed data. Some other error codes are possible too. The method could panic or leave depending on the state of iAssertObj member of RResourceFileImpl::TExtra class.

Parameters

TInt aResourceIndex
TUint aFlags
const SDictionaryCompressionData & aDictionaryCompressionData
const TDesC16 & aIndex

FirstRecordL()

SSigRecord FirstRecordL()const [private]
panic
Some BAFL panic codes, if the file is corrupted.
leave
KErrCorrupt The file is corrupted. Some other error codes are possible too. The method could panic or leave depending on the state of iAssertObj member of RResourceFileImpl::TExtra class.

LittleEndianTwoByteIntegerL(const TDesC8 &, TInt)

TInt LittleEndianTwoByteIntegerL(const TDesC8 &aBuffer,
TIntaIndexOfFirstByte
)const [private]
Pre-condition
OpenL() is called.

Parameters

const TDesC8 & aBuffer
TInt aIndexOfFirstByte

Offset()

TInt Offset()const

Returns the offset value defined for this resource file.

This function must not be called until a call to ConfirmSignatureL() has completed successfully, otherwise the value returned by this function may be meaningless.

ConfirmSignatureL()
Pre-condition
OpenL() is called.

OpenL(RFs &, const TDesC &, const TBaAssert &, TUint, TInt)

voidOpenL(RFs &aFs,
const TDesC &aName,
const TBaAssert &aAssert,
TUintaFileOffset = 0,
TIntaFileSize = 0
)
Opens the resource file reader. The resource file reader must be opened before reading resources or checking the signature of the resource file. This function initially closes the resource-file object if it is currently open. If a leave occurs during the function, the object is reverted to its closed state.
panic
Some BAFL panic codes.
leave
KErrCorrupt The file is corrupted. The method could panic or leave depending on the state of iAssertObj member of RResourceFileImpl::TExtra class.

Parameters

RFs & aFsHandle to a file server session.
const TDesC & aNameFile to open as a resource file.
const TBaAssert & aAssertObject which will be used to determine panic/leave behaviour of the "L" methods.
TUint aFileOffset = 0The resource file section offset from the beginning of the file.
TInt aFileSize = 0The resource file section size.

OpenL(const TDesC8 &, const TBaAssert &)

voidOpenL(const TDesC8 &aRscArchive,
const TBaAssert &aAssert
)
Opens the resource file reader. The resource file reader must be opened before reading resources or checking the signature of the resource file. This function initially closes the resource-file object if it is currently open. If a leave occurs during the function, the object is reverted to its closed state.
panic
Some BAFL panic codes.
leave
KErrCorrupt The file is corrupted. The method could panic or leave depending on the state of iAssertObj member of RResourceFileImpl::TExtra class.

Parameters

const TDesC8 & aRscArchivebuffer containing a full rsc file
const TBaAssert & aAssertObject which will be used to determine panic/leave behaviour of the "L" methods.

OwnsResourceIdL(TInt)

TBool OwnsResourceIdL(TIntaResourceId)const

Tests whether the resource file owns the specified resource id.

The resource file owns the resource id if the most significant 20 bits of the resource id are zero or match the offset value as returned from a call to the Offset() member function or if the resource id is not out of range.

Offset()
Pre-condition
OpenL() is called.
panic
Some BAFL panic codes, if the file is corrupted.
leave
KErrCorrupt The file is corrupted. Some other error codes are possible too. The method could panic or leave depending on the state of iAssertObj member of RResourceFileImpl::TExtra class.

Parameters

TInt aResourceIdThe resource id to test.

ReadHeaderAndResourceIndexL()

voidReadHeaderAndResourceIndexL()[private]
Function to retrieve the header information of the rsc file and all the resource index information in the rsc file. This function is created to handle the common functionality in the two OpenL() method.
Pre-condition
OpenL() is called.

ReadL(TDes8 &, TInt)

voidReadL(TDes8 &aDes,
TIntaResourceId
)const
Reads a resource specified by resource id into the specified descriptor. The descriptor must be long enough to contain the entire resource. The search for the resource uses the following algorithm: A resource id in the range 1 to 4095 is looked up in this resource file. The function leaves if there is no matching resource. If the resource id is greater than 4095, then the most significant 20 bits of the resource id is treated as an offset and the least significant 12 bits is treated as the real resource id. If the offset matches the offset value defined for this file, then the resource is looked up in this resource file using the real resource id (i.e. the least significant 12 bits). If the offset does not match, then the function leaves. Note, do not call this function until a call to ConfirmSignatureL() has completed successfully.
Pre-condition
OpenL() is called.
ConfirmSignatureL()
panic
Some BAFL panic codes, if the file is corrupted.
leave
KErrCorrupt The file is corrupted. Some other error codes are possible too. The method could panic or leave depending on the state of iAssertObj member of RResourceFileImpl::TExtra class.

Parameters

TDes8 & aDesOn return, contains the resource that has been read. The function leaves if the descriptor is not long enough to contain the entire resource.
TInt aResourceIdThe numeric id of the resource to be read. The function leaves if this resource id is not in this resource file.

ReadL(TInt, TDes8 &, TInt)

voidReadL(TIntaPos,
TDes8 &aDes,
TIntaLength
)const [private]
Pre-condition
OpenL() is called.

Parameters

TInt aPos
TDes8 & aDes
TInt aLength

ReadL(TUint, TInt, TDes8 &, TInt)

voidReadL(TUintaFlags,
TIntaPos,
TDes8 &aDes,
TIntaLength
)const [private]
Pre-condition
OpenL() is called.

Parameters

TUint aFlags
TInt aPos
TDes8 & aDes
TInt aLength

SignatureL()

TInt SignatureL()const
Pre-condition
OpenL() is called.
panic
Some BAFL panic codes, if the file is corrupted.
leave
KErrCorrupt The file is corrupted. Some other error codes are possible too. The method could panic or leave depending on the state of iAssertObj member of RResourceFileImpl::TExtra class.

UidType()

TUidType UidType()const

Retrieve the UID tuple of the opened resource file.

Pre-condition
OpenL() has been called successfully.
panic
BAFL 36 - data members are not initialized(probably - OpenL() hasn't been called).

Member Enumerations Documentation

Enum anonymous

Enumerators

EFlagIsRomFile = 0x80000000
EFlagPotentiallyContainsCompressedUnicode = 0x40000000
EFlagDictionaryCompressed = 0x20000000
EFlagThirdUidIsOffset = 0x10000000
EFlagGenerate_RSS_SIGNATURE_ForFirstUserResource = 0x08000000
EFlagFirstResourceIsGeneratedBitArrayOfResourcesContainingCompressedUnicode = 0x04000000
EFlagCalypsoFileFormat = 0x02000000
EFlagIsBufferRscFile = 0x01000000
EAllFlags = 0xff000000

Enum anonymous

Enumerators

EOffsetBits = 0xfffff000
EIdBits = 0x00000fff

Member Data Documentation

TExtra * iExtra

TExtra *iExtra[private]

TAny * iFile

TAny *iFile[private]

TUint iFlagsAndNumberOfResources

TUint iFlagsAndNumberOfResources[private]

HBufC16 * iIndex

HBufC16 *iIndex[private]

TInt iOffset

TInt iOffset[private]

TInt iSizeOfLargestResourceWhenCompletelyUncompressed

TInt iSizeOfLargestResourceWhenCompletelyUncompressed[private]