|
1 /* |
|
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 #include "FSResources.h" |
|
21 #include <fstokenserver.rsg> |
|
22 |
|
23 _LIT(KResourceFile, "Z:\\RESOURCE\\FSTOKENSERVER.RSC"); |
|
24 |
|
25 CDesCArray* FSResources::iStrings; |
|
26 |
|
27 /// If the resources aren't initialised, initialise them |
|
28 void FSResources::InitialiseL() |
|
29 { |
|
30 if (iStrings != NULL) |
|
31 return; |
|
32 |
|
33 RFs fs; |
|
34 User::LeaveIfError(fs.Connect()); |
|
35 |
|
36 TFileName fileName; |
|
37 fileName.Copy(KResourceFile); |
|
38 |
|
39 CleanupClosePushL(fs); |
|
40 BaflUtils::NearestLanguageFile(fs,fileName); |
|
41 if (!BaflUtils::FileExists(fs,fileName)) |
|
42 { |
|
43 User::Leave(KErrNotFound); |
|
44 } |
|
45 |
|
46 RResourceFile resourceFile; |
|
47 resourceFile.OpenL(fs,fileName); |
|
48 CleanupClosePushL(resourceFile); |
|
49 resourceFile.ConfirmSignatureL(0); |
|
50 resourceFile.Offset(); |
|
51 TResourceReader reader; |
|
52 HBufC8* resource = resourceFile.AllocReadLC(R_FSSERVER_STRINGS); |
|
53 reader.SetBuffer(resource); |
|
54 |
|
55 iStrings = reader.ReadDesCArrayL(); |
|
56 |
|
57 |
|
58 CleanupStack::PopAndDestroy(3); // Close reader, file and fs |
|
59 } |
|
60 |
|
61 /// Free all resources. |
|
62 void FSResources::Cleanup() |
|
63 { |
|
64 delete iStrings; |
|
65 iStrings = NULL; |
|
66 } |
|
67 |
|
68 /// Returns an array of strings. The strings are identified by |
|
69 /// enums in TStrings |
|
70 const RCPointerArray<HBufC>& Strings(); |