RConeResourceLoader Class Reference

API published in: S60 2nd Ed

Link against: commonengine.lib

Capability Information

Required Capabilities

None


#include <coneresloader.h>

Detailed 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. Cone Resource Loader API consist of the RConeResourceLoader class.

Only one resource at a time may be open by one RConeResourceLoader instance. You can use several RConeResourceLoader 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 to search for a localised resource in proper search order.

Usage example:

  #include <ConeResLoader.h>  

  // Get CCoeEnv instance
  CEikonEnv* eikEnv = CEikonEnv::Static();

  // Initialize loader
  RConeResourceLoader rLoader(eikEnv);

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

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

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

  // Pop and destroy rLoader from stack. 
  // This also calls close on rLoader since CleanupClosePushL was used.
  CleanupStack::PopAndDestroy(); // rLoader

Public Member Functions

IMPORT_C  RConeResourceLoader (CCoeEnv &aEnv)
  Constructor.
IMPORT_C TInt  Open (TFileName &aFileName)
  Opens the resource file for reading.
IMPORT_C void  OpenL (TFileName &aFileName)
  Opens the resource file for reading.
IMPORT_C void  Close ()
  Closes the opened resource file, if one is open.

Constructor & Destructor Documentation

IMPORT_C RConeResourceLoader::RConeResourceLoader CCoeEnv &  aEnv  ) 
 

Constructor.

Parameters:
aEnv  is a reference to Control environment in which resource is loaded.

Member Function Documentation

IMPORT_C void RConeResourceLoader::Close  ) 
 

Closes the opened resource file, if one is open.

Does nothing if no file has been opened. New resource file may be opened after the previous has been closed. Always remember to close the resource when finished using it.

IMPORT_C TInt RConeResourceLoader::Open TFileName &  aFileName  ) 
 

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 to search for a localized resource file in proper search order.

Parameters:
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.
Returns:
a Symbian OS error code.
Panic:
KErrNotSupported The instance already has a file open.
IMPORT_C void RConeResourceLoader::OpenL TFileName &  aFileName  ) 
 

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 to search for a localized resource file in proper search order.

Parameters:
aFileName  Reference for resource file name. Please note that drive letter is required !
Leave:
KErrNotSupported The instance already has a file open.

The documentation for this class was generated from the following file:

Copyright © Nokia Corporation 2001-2008
Back to top