epoc32/include/mw/coeutils.h
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/mw/coeutils.h	Wed Mar 31 12:27:01 2010 +0100
     1.3 @@ -0,0 +1,102 @@
     1.4 +// COEUTILS.H
     1.5 +
     1.6 +/*
     1.7 +* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.8 +* All rights reserved.
     1.9 +* This component and the accompanying materials are made available
    1.10 +* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
    1.11 +* which accompanies this distribution, and is available
    1.12 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.13 +*
    1.14 +* Initial Contributors:
    1.15 +* Nokia Corporation - initial contribution.
    1.16 +*
    1.17 +* Contributors:
    1.18 +*
    1.19 +* Description:
    1.20 +*
    1.21 +*/
    1.22 +
    1.23 +
    1.24 +
    1.25 +#ifndef __COEUTILS_H__
    1.26 +#define __COEUTILS_H__
    1.27 +
    1.28 +#include <e32std.h>
    1.29 +class CCoeEnv;
    1.30 +
    1.31 +/** Provides file and path utility functions.
    1.32 +
    1.33 +@publishedAll
    1.34 +@released */
    1.35 +class ConeUtils
    1.36 +	{
    1.37 +public:
    1.38 +	IMPORT_C static TBool FileExists(const TDesC& aFileName);
    1.39 +	IMPORT_C static void EnsurePathExistsL(const TPtrC& aFileName);
    1.40 +	};
    1.41 +
    1.42 +
    1.43 +/** 
    1.44 +Class encapsulates methods for opening and closing localised resource files
    1.45 +in the CONE environment. The actual reading of resources from an opened 
    1.46 +resource file is done using various CCoeEnv provided resource-reading 
    1.47 +methods. The Cone Resource Loader API consists of the RCoeResourceLoader class.
    1.48 +
    1.49 +Only one resource at a time may be opened by one RCoeResourceLoader instance. 
    1.50 +You can use several RCoeResourceLoader instances for accessing several 
    1.51 +resources simultaneously or use one instance and close the previous resource
    1.52 +before opening a new one.
    1.53 +
    1.54 +The implementation uses BaflUtils::NearestLanguageFile to search for
    1.55 +a localised resource in proper search order.
    1.56 + 
    1.57 +Usage example:  
    1.58 +
    1.59 +@code
    1.60 +#include <coeutils.h>  
    1.61 +
    1.62 +// Get CCoeEnv instance
    1.63 +CEikonEnv* eikEnv = CEikonEnv::Static();
    1.64 +// Initialize loader
    1.65 +RCoeResourceLoader rLoader(eikEnv);
    1.66 +
    1.67 +// Push resource loader to cleanup stack, so that it will always be properly 
    1.68 +// closed when popped.
    1.69 +CleanupClosePushL(rLoader);
    1.70 +
    1.71 +// Open resource file
    1.72 +_LIT( KSampleResourceFileName, "Z:\\System\\Apps\\sample\\sample.rsc" );
    1.73 +TFileName fileName(KSampleResourceFileName);
    1.74 +rLoader.OpenL(fileName);
    1.75 +
    1.76 +// Read a resource   
    1.77 +iSomeArray = eikEnv->ReadDesC16ArrayResourceL(R_SOME_RESOURCE);
    1.78 +
    1.79 +// Pop and destroy rLoader from stack. 
    1.80 +// This also calls the rLoader close function after CleanupClosePushL is used.
    1.81 +CleanupStack::PopAndDestroy(); // rLoader
    1.82 +@endcode
    1.83 +
    1.84 +@publishedAll
    1.85 +@released */
    1.86 +NONSHARABLE_CLASS(RCoeResourceLoader)
    1.87 +    {
    1.88 +public:
    1.89 +    IMPORT_C RCoeResourceLoader(CCoeEnv& aEnv);
    1.90 +    IMPORT_C TInt Open(TFileName& aFileName);
    1.91 +    IMPORT_C void OpenL(TFileName& aFileName);
    1.92 +    IMPORT_C void Close();
    1.93 +private:
    1.94 +    // Prohibit copy constructor and assigment operator because not deriving from CBase.
    1.95 +    RCoeResourceLoader();
    1.96 +    RCoeResourceLoader(const RCoeResourceLoader&);
    1.97 +    RCoeResourceLoader& operator= (const RCoeResourceLoader&);
    1.98 +private:
    1.99 +    // Needed for closing
   1.100 +    CCoeEnv& iEnv; 
   1.101 +    TInt iResourceFileOffset;
   1.102 +    };
   1.103 +
   1.104 +
   1.105 +#endif	// __COEUTILS_H__