CResourceFile Class Reference

class CResourceFile : public CBase

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

Interpretation of the data is achieved using the RResourceReader class. CResourceFile methods behaviour when some problem occurs - it leaves with an error code. Most of the time the error code will be KErrCorrupt.

RResourceReader

Inherits from

Constructor & Destructor Documentation

CResourceFile()

CResourceFile ( ) [private]

Default constructor. Initializes in place the implementation object.

CResourceFile(const CResourceFile &)

CResourceFile ( const CResourceFile & ) [private]

Parameters

const CResourceFile &

~CResourceFile()

IMPORT_C ~CResourceFile ( ) [virtual]

Frees the resources, allocated by the instance.

Member Functions Documentation

AllocReadL(TInt)

IMPORT_C HBufC8 * AllocReadL ( TInt aResourceId ) const

Reads a resource into a heap descriptor and returns a pointer to that descriptor.

A heap descriptor of appropriate length is allocated for the resource. Ownership of the heap descriptor passes to the caller who must destroy it 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.

leave
The function leaves if this resource id is not in this resource file or the file is corrupted.
RResourceFile::Offset()

Parameters

TInt aResourceId The numeric id of the resource to be read.

AllocReadLC(TInt)

IMPORT_C HBufC8 * AllocReadLC ( TInt aResourceId ) 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.

leave
The function leaves if this resource id is not in this resource file or the file is corrupted.
RResourceFile::Offset()

Parameters

TInt aResourceId The numeric id of the resource to be read.

ConfirmSignatureL(TInt)

IMPORT_C 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() .

leave
The function leaves if this resource id is not in this resource file or the file is corrupted.

Parameters

TInt aSignature This argument value is not used by the function.

ConfirmSignatureL()

IMPORT_C void 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() .
leave
The function leaves if this resource id is not in this resource file or the file is corrupted.

ConstructL(RFs &, const TDesC &, TUint, TInt)

void ConstructL ( RFs & aFs,
const TDesC & aName,
TUint aFileOffset,
TInt aFileSize
) [private]
leave
KErrCorrupt if the file is corrupted.
leave
KErrNoMemory if there is not enough memory for the object.

Parameters

RFs & aFs Handle to a file server session.
const TDesC & aName File to open as a resource file.
TUint aFileOffset The resource file section offset from the beginning of the file.
TInt aFileSize The resource file section size.

ConstructL(const TDesC8 &)

void ConstructL ( const TDesC8 & aRscFileBuffer ) [private]
leave
KErrCorrupt if the file buffer is corrupted.
leave
KErrNoMemory if there is not enough memory for the object.

Parameters

const TDesC8 & aRscFileBuffer a buffer containing a full rsc file

Impl()

RResourceFileImpl * Impl ( ) [private]

Impl()

const RResourceFileImpl * Impl ( ) const [private]

NewL(RFs &, const TDesC &, TUint, TInt)

IMPORT_C CResourceFile * NewL ( RFs & aFs,
const TDesC & aName,
TUint aFileOffset,
TInt aFileSize
) [static]
Creates CResourceFile instance.
leave
KErrCorrupt if the file is corrupted.
leave
KErrNoMemory if there is not enough memory for the object.

Parameters

RFs & aFs Handle to a file server session.
const TDesC & aName File to open as a resource file.
TUint aFileOffset The resource file section offset from the beginning of the file.
TInt aFileSize The resource file section size.

NewL(const TDesC8 &)

IMPORT_C CResourceFile * NewL ( const TDesC8 & aRscFileBuffer ) [static]
Creates CResourceFile instance.
leave
KErrCorrupt if the file buffer is corrupted.
leave
KErrNoMemory if there is not enough memory for the object.

Parameters

const TDesC8 & aRscFileBuffer a buffer containing one entire resource file

NewLC(RFs &, const TDesC &, TUint, TInt)

IMPORT_C CResourceFile * NewLC ( RFs & aFs,
const TDesC & aName,
TUint aFileOffset,
TInt aFileSize
) [static]
Creates CResourceFile instance.
leave
KErrCorrupt if the file is corrupted.
leave
KErrNoMemory if there is not enough memory for the object.

Parameters

RFs & aFs Handle to a file server session.
const TDesC & aName File to open as a resource file.
TUint aFileOffset The resource file section offset from the beginning of the file.
TInt aFileSize The resource file section size.

Offset()

IMPORT_C 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.

OwnsResourceIdL(TInt)

IMPORT_C TBool OwnsResourceIdL ( TInt aResourceId ) 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.
leave
KErrCorrupt - the file is corrupted. Some other error codes are possible.

Parameters

TInt aResourceId The resource id to test.

ReadL(TDes8 &, TInt)

IMPORT_C 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.

leave
The function leaves if this resource id is not in this resource file or the file is corrupted.

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.

SignatureL()

IMPORT_C TInt SignatureL ( ) const

Returns this resource file's version number.

The function assumes that the first resource in the file consists of two 32-bit integers. The first integer contains the version number.
leave
KErrCorrupt - the file is corrupted.
RResourceFile::ConfirmSignatureL()

UidType()

IMPORT_C TUidType UidType ( ) const

Returns this resource file's UIDs.

operator=(const CResourceFile &)

CResourceFile & operator= ( const CResourceFile & ) [private]

Parameters

const CResourceFile &

Member Enumerations Documentation

Enum anonymous

Enumerators

KRscFileSize = 24

Member Data Documentation

TUint8 iImpl

TUint8 iImpl [private]