|
1 /* |
|
2 * Copyright (c) 2008-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 "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: Utility for loading resource files |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // CLASS HEADER |
|
21 #include "glxresourceutilities.h" |
|
22 |
|
23 // EXTERNAL INCLUDES |
|
24 #include <bautils.h> |
|
25 #include <AknUtils.h> |
|
26 #include <f32file.h> |
|
27 #include <data_caging_path_literals.hrh> |
|
28 |
|
29 _LIT(KGlxUiUtilitiesResource, "glxuiutilities.rsc"); |
|
30 // INTERNAL INCLUDES |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // GetResourceFilenameL |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 EXPORT_C void CGlxResourceUtilities::GetResourceFilenameL( TFileName& aResFile ) |
|
37 { |
|
38 RFs fs; |
|
39 User::LeaveIfError( fs.Connect() ); |
|
40 CleanupClosePushL( fs ); |
|
41 CGlxResourceUtilities::GetResourceFilenameL( aResFile, fs ); |
|
42 CleanupStack::PopAndDestroy( &fs ); |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // GetResourceFilenameL |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 EXPORT_C void CGlxResourceUtilities::GetResourceFilenameL( TFileName& aResFile, RFs& aFs ) |
|
50 { |
|
51 // don't use AknUtils CompleteWithAppPath |
|
52 aResFile.Insert( 0, TDriveUnit( EDriveC).Name() ); |
|
53 // try to locate the localised resource |
|
54 BaflUtils::NearestLanguageFile( aFs, aResFile ); |
|
55 // if the localised resource is found, the file name is changed to |
|
56 // the localised name (z:\apps\resources\xxx.r001) |
|
57 if( !BaflUtils::FileExists( aFs, aResFile ) ) |
|
58 { |
|
59 // not found on c drive, try z |
|
60 aResFile.Replace( 0, KMaxDriveName, TDriveUnit( EDriveZ ).Name() ); |
|
61 // try to locate the localised resource again |
|
62 BaflUtils::NearestLanguageFile( aFs, aResFile ); |
|
63 // if file was not found this time, there is no localised |
|
64 // resource with the name |
|
65 if (!BaflUtils::FileExists( aFs, aResFile ) ) |
|
66 { |
|
67 User::Leave( KErrNotFound ); |
|
68 } |
|
69 } |
|
70 } |
|
71 // --------------------------------------------------------------------------- |
|
72 // GetUiUtilitiesResourceFilenameL |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 EXPORT_C TFileName CGlxResourceUtilities::GetUiUtilitiesResourceFilenameL() |
|
76 |
|
77 { |
|
78 TParse parse; |
|
79 parse.Set(KGlxUiUtilitiesResource, &KDC_APP_RESOURCE_DIR, NULL); |
|
80 TFileName resourceFile(parse.FullName()); |
|
81 GetResourceFilenameL(resourceFile); |
|
82 return resourceFile; |
|
83 } |