Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

#include <COEUTILS.H>
Link against: cone.lib

Class RCoeResourceLoader

class RCoeResourceLoader;

Description

Class encapsulates methods for opening and closing localised resource files in the CONE environment. The actual reading of resources from an opened resource file is done using various CCoeEnv provided resource-reading methods. The Cone Resource Loader API consists of the RCoeResourceLoader class.

Only one resource at a time may be opened by one RCoeResourceLoader instance. You can use several RCoeResourceLoader instances for accessing several resources simultaneously or use one instance and close the previous resource before opening a new one.

The implementation uses BaflUtils::NearestLanguageFile(const RFs &,TFileName &) to search for a localised resource in proper search order.

Usage example:

#include <coeutils.h>  

// Get CCoeEnv instance
CEikonEnv* eikEnv = CEikonEnv::Static();
// Initialize loader
RCoeResourceLoader rLoader(eikEnv);

// Push resource loader to cleanup stack, so that it will always be properly 
// closed when popped.
CleanupClosePushL(rLoader);

// Open resource file
_LIT( KSampleResourceFileName, "Z:\\System\\Apps\\sample\\sample.rsc" );
TFileName fileName(KSampleResourceFileName);
rLoader.OpenL(fileName);

// Read a resource   
iSomeArray = eikEnv->ReadDesC16ArrayResourceL(R_SOME_RESOURCE);

// Pop and destroy rLoader from stack. 
// This also calls the rLoader close function after CleanupClosePushL is used.
CleanupStack::PopAndDestroy(); // rLoader

Members

Defined in RCoeResourceLoader:


Construction and destruction


RCoeResourceLoader(CCoeEnv &)

IMPORT_C RCoeResourceLoader(CCoeEnv &aEnv);

Description

Constructor.

Parameters

CCoeEnv &aEnv

is a reference to Control environment in which resource is loaded.

[Top]


Member functions


Open(TFileName &)

IMPORT_C TInt Open(TFileName &aFileName);

Description

Opens the resource file for reading. Only one resource may be open at a time. Panics if this instance already has a file open. The implementation uses BaflUtils::NearestLanguageFile(const RFs &,TFileName &) to search for a localized resource file in proper search order.

Parameters

TBuf &aFileName

is the resource file name to open. This parameter value is changed to the best matching language file found. The drive letter is required in the filename.

Return value

TInt

a Symbian OS error code.

Panic codes

KErrNotSupported

The instance already has a file open.


OpenL(TFileName &)

IMPORT_C void OpenL(TFileName &aFileName);

Description

Opens the resource file for reading. Only one resource may be open at a time. Leaves if this instance already has a file open. The implementation uses BaflUtils::NearestLanguageFile(const RFs &,TFileName &) to search for a localized resource file in proper search order.

Parameters

TBuf &aFileName

Reference for resource file name. Note that drive letter is required.

Leave codes

KErrNotSupported

The instance already has a file open.

Panic codes

CONE

15 The resource file has no NAME statement (i.e. has no offset).


Close()

IMPORT_C void Close();

Description