RResourceFileImpl Class Reference
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
Nested Classes and Structures
Private Member Functions |
---|
void | AppendDecompressedUnicodeL(TDes8 &, const TDesC8 &) |
void | AppendDictionaryCompressionBitStreamL(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) |
void | ReadHeaderAndResourceIndexL() |
void | ReadL(TInt, TDes8 &, TInt) |
void | ReadL(TUint, TInt, TDes8 &, TInt) |
Constructor & Destructor Documentation
Member Functions Documentation
AllocReadLC(TInt)
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 aResourceId | The numeric id of the resource to be read. |
AppendDecompressedUnicodeL(TDes8 &, const TDesC8 &)
void | AppendDecompressedUnicodeL | ( | 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 & aBuffer | Destination buffer. |
const TDesC8 & aCompressedUnicode | Compressed unicode buffer. |
AppendDictionaryCompressionBitStreamL(RArray< RDictionaryCompressionBitStream > &, TUint, const SDictionaryCompressionData &, TInt, TInt, TInt)
void | AppendDictionaryCompressionBitStreamL | ( | RArray< RDictionaryCompressionBitStream > & | aStackOfDictionaryCompressionBitStreams, |
| TUint | aFlags, |
| const SDictionaryCompressionData & | aDictionaryCompressionData, |
| TInt | aStartOfBitData, |
| TInt | aStartOfIndex, |
| TInt | aIndexEntry |
| ) | 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.
Close()
Closes the resource file reader. This function is called after finishing reading all resources.
ConfirmSignatureL(TInt)
void | ConfirmSignatureL | ( | TInt | aSignature | ) | |
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 aSignature | This argument value is not used by the function. |
ConfirmSignatureL()
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, |
| TInt | aSizeOfLargestResourceWhenCompletelyUncompressed |
| ) | 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 & aDictionaryDecompressedResourceData | Compressed data. |
TInt aSizeOfLargestResourceWhenCompletelyUncompressed | The size of decomressed data. |
DictionaryDecompressedResourceDataLC(TInt, TUint, const SDictionaryCompressionData &, const TDesC16 &)
HBufC8 * | DictionaryDecompressedResourceDataLC | ( | TInt | aResourceIndex, |
| TUint | aFlags, |
| 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()
-
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, |
| TInt | aIndexOfFirstByte |
| ) | const [private] |
Offset()
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.
OpenL(RFs &, const TDesC &, const TBaAssert &, TUint, TInt)
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 & aFs | Handle to a file server session. |
const TDesC & aName | File to open as a resource file. |
const TBaAssert & aAssert | Object which will be used to determine panic/leave behaviour of the "L" methods. |
TUint aFileOffset = 0 | The resource file section offset from the beginning of the file. |
TInt aFileSize = 0 | The resource file section size. |
OpenL(const TDesC8 &, const TBaAssert &)
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 & aRscArchive | buffer containing a full rsc file |
const TBaAssert & aAssert | Object which will be used to determine panic/leave behaviour of the "L" methods. |
OwnsResourceIdL(TInt)
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 aResourceId | The resource id to test. |
ReadHeaderAndResourceIndexL()
void | ReadHeaderAndResourceIndexL | ( | ) | [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)
void | ReadL | ( | TDes8 & | aDes, |
| TInt | aResourceId |
| ) | 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 & aDes | On return, contains the resource that has been read. The function leaves if the descriptor is not long enough to contain the entire resource. |
TInt aResourceId | The 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)
ReadL(TUint, TInt, TDes8 &, TInt)
SignatureL()
- 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()
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
TUint
iFlagsAndNumberOfResources
TUint
| iFlagsAndNumberOfResources | [private] |
TInt
iSizeOfLargestResourceWhenCompletelyUncompressed
TInt
| iSizeOfLargestResourceWhenCompletelyUncompressed | [private] |
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.