4 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
6 * This component and the accompanying materials are made available
7 * under the terms of "Eclipse Public License v1.0"
8 * which accompanies this distribution, and is available
9 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
11 * Initial Contributors:
12 * Nokia Corporation - initial contribution.
22 #ifndef __COEUTILS_H__
23 #define __COEUTILS_H__
28 /** Provides file and path utility functions.
35 IMPORT_C static TBool FileExists(const TDesC& aFileName);
36 IMPORT_C static void EnsurePathExistsL(const TPtrC& aFileName);
41 Class encapsulates methods for opening and closing localised resource files
42 in the CONE environment. The actual reading of resources from an opened
43 resource file is done using various CCoeEnv provided resource-reading
44 methods. The Cone Resource Loader API consists of the RCoeResourceLoader class.
46 Only one resource at a time may be opened by one RCoeResourceLoader instance.
47 You can use several RCoeResourceLoader instances for accessing several
48 resources simultaneously or use one instance and close the previous resource
49 before opening a new one.
51 The implementation uses BaflUtils::NearestLanguageFile to search for
52 a localised resource in proper search order.
59 // Get CCoeEnv instance
60 CEikonEnv* eikEnv = CEikonEnv::Static();
62 RCoeResourceLoader rLoader(eikEnv);
64 // Push resource loader to cleanup stack, so that it will always be properly
65 // closed when popped.
66 CleanupClosePushL(rLoader);
69 _LIT( KSampleResourceFileName, "Z:\\System\\Apps\\sample\\sample.rsc" );
70 TFileName fileName(KSampleResourceFileName);
71 rLoader.OpenL(fileName);
74 iSomeArray = eikEnv->ReadDesC16ArrayResourceL(R_SOME_RESOURCE);
76 // Pop and destroy rLoader from stack.
77 // This also calls the rLoader close function after CleanupClosePushL is used.
78 CleanupStack::PopAndDestroy(); // rLoader
83 NONSHARABLE_CLASS(RCoeResourceLoader)
86 IMPORT_C RCoeResourceLoader(CCoeEnv& aEnv);
87 IMPORT_C TInt Open(TFileName& aFileName);
88 IMPORT_C void OpenL(TFileName& aFileName);
89 IMPORT_C void Close();
91 // Prohibit copy constructor and assigment operator because not deriving from CBase.
93 RCoeResourceLoader(const RCoeResourceLoader&);
94 RCoeResourceLoader& operator= (const RCoeResourceLoader&);
98 TInt iResourceFileOffset;
102 #endif // __COEUTILS_H__