1 coeutils.h |
1 // COEUTILS.H |
|
2 |
|
3 /* |
|
4 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
5 * All rights reserved. |
|
6 * This component and the accompanying materials are made available |
|
7 * 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 |
|
8 * which accompanies this distribution, and is available |
|
9 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
10 * |
|
11 * Initial Contributors: |
|
12 * Nokia Corporation - initial contribution. |
|
13 * |
|
14 * Contributors: |
|
15 * |
|
16 * Description: |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 #ifndef __COEUTILS_H__ |
|
23 #define __COEUTILS_H__ |
|
24 |
|
25 #include <e32std.h> |
|
26 class CCoeEnv; |
|
27 |
|
28 /** Provides file and path utility functions. |
|
29 |
|
30 @publishedAll |
|
31 @released */ |
|
32 class ConeUtils |
|
33 { |
|
34 public: |
|
35 IMPORT_C static TBool FileExists(const TDesC& aFileName); |
|
36 IMPORT_C static void EnsurePathExistsL(const TPtrC& aFileName); |
|
37 }; |
|
38 |
|
39 |
|
40 /** |
|
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. |
|
45 |
|
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. |
|
50 |
|
51 The implementation uses BaflUtils::NearestLanguageFile to search for |
|
52 a localised resource in proper search order. |
|
53 |
|
54 Usage example: |
|
55 |
|
56 @code |
|
57 #include <coeutils.h> |
|
58 |
|
59 // Get CCoeEnv instance |
|
60 CEikonEnv* eikEnv = CEikonEnv::Static(); |
|
61 // Initialize loader |
|
62 RCoeResourceLoader rLoader(eikEnv); |
|
63 |
|
64 // Push resource loader to cleanup stack, so that it will always be properly |
|
65 // closed when popped. |
|
66 CleanupClosePushL(rLoader); |
|
67 |
|
68 // Open resource file |
|
69 _LIT( KSampleResourceFileName, "Z:\\System\\Apps\\sample\\sample.rsc" ); |
|
70 TFileName fileName(KSampleResourceFileName); |
|
71 rLoader.OpenL(fileName); |
|
72 |
|
73 // Read a resource |
|
74 iSomeArray = eikEnv->ReadDesC16ArrayResourceL(R_SOME_RESOURCE); |
|
75 |
|
76 // Pop and destroy rLoader from stack. |
|
77 // This also calls the rLoader close function after CleanupClosePushL is used. |
|
78 CleanupStack::PopAndDestroy(); // rLoader |
|
79 @endcode |
|
80 |
|
81 @publishedAll |
|
82 @released */ |
|
83 NONSHARABLE_CLASS(RCoeResourceLoader) |
|
84 { |
|
85 public: |
|
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(); |
|
90 private: |
|
91 // Prohibit copy constructor and assigment operator because not deriving from CBase. |
|
92 RCoeResourceLoader(); |
|
93 RCoeResourceLoader(const RCoeResourceLoader&); |
|
94 RCoeResourceLoader& operator= (const RCoeResourceLoader&); |
|
95 private: |
|
96 // Needed for closing |
|
97 CCoeEnv& iEnv; |
|
98 TInt iResourceFileOffset; |
|
99 }; |
|
100 |
|
101 |
|
102 #endif // __COEUTILS_H__ |