photosgallery/common/src/glxresourceutilities.cpp
changeset 0 4e91876724a2
child 15 191387a8b767
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     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 
       
    21 //  CLASS HEADER
       
    22 #include "glxresourceutilities.h"
       
    23     
       
    24 //  EXTERNAL INCLUDES
       
    25 #include <bautils.h>
       
    26 #include <AknUtils.h>
       
    27 #include <f32file.h>
       
    28 
       
    29 //  INTERNAL INCLUDES
       
    30 
       
    31 // ---------------------------------------------------------------------------
       
    32 // GetResourceFilenameL
       
    33 // ---------------------------------------------------------------------------
       
    34 //
       
    35 EXPORT_C void CGlxResourceUtilities::GetResourceFilenameL( TFileName& aResFile )
       
    36     {
       
    37 	RFs fs;
       
    38     User::LeaveIfError( fs.Connect() );
       
    39     CleanupClosePushL( fs );
       
    40     CGlxResourceUtilities::GetResourceFilenameL( aResFile, fs );
       
    41     CleanupStack::PopAndDestroy( &fs );
       
    42     }
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // GetResourceFilenameL
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 EXPORT_C void CGlxResourceUtilities::GetResourceFilenameL( TFileName& aResFile, RFs& aFs )
       
    49     {
       
    50     // don't use AknUtils CompleteWithAppPath  
       
    51     aResFile.Insert( 0, TDriveUnit( EDriveC).Name() );
       
    52 	// try to locate the localised resource
       
    53     BaflUtils::NearestLanguageFile( aFs, aResFile );
       
    54     // if the localised resource is found, the file name is changed to 
       
    55     // the localised name (z:\apps\resources\xxx.r001)
       
    56     if( !BaflUtils::FileExists( aFs, aResFile ) )
       
    57         {
       
    58         // not found on c drive, try z
       
    59         aResFile.Replace( 0, KMaxDriveName, TDriveUnit( EDriveZ ).Name() );
       
    60     	// try to locate the localised resource again
       
    61         BaflUtils::NearestLanguageFile( aFs, aResFile );
       
    62         // if file was not found this time, there is no localised 
       
    63         // resource with the name
       
    64         if (!BaflUtils::FileExists( aFs, aResFile ) )
       
    65             {
       
    66             User::Leave( KErrNotFound );
       
    67             }
       
    68         }
       
    69     }
       
    70 
       
    71