menufw/hierarchynavigator/hnmetadatamodel/src/hnutils.cpp
branchRCL_3
changeset 26 1b758917cafc
parent 0 f72a12da539e
equal deleted inserted replaced
25:137ebc85284b 26:1b758917cafc
    73 
    73 
    74 // ---------------------------------------------------------------------------
    74 // ---------------------------------------------------------------------------
    75 // 
    75 // 
    76 // ---------------------------------------------------------------------------
    76 // ---------------------------------------------------------------------------
    77 //      
    77 //      
    78 EXPORT_C HBufC* HnUtils::LocateFileLC( const TDesC& aFile )
       
    79     {
       
    80     HBufC* filePath = HBufC::NewLC(KMaxName);
       
    81     RFs& fs = CEikonEnv::Static()->FsSession();
       
    82 
       
    83     TDriveList driveList;
       
    84     TChar driveLetter;
       
    85     TInt driveNumber=EDriveY;
       
    86     User::LeaveIfError(fs.DriveList(driveList));
       
    87     for(; driveNumber>=EDriveA-1; driveNumber-- )
       
    88         {
       
    89         if (driveNumber==EDriveA-1)
       
    90         driveNumber = EDriveZ;
       
    91         if (driveList[driveNumber])
       
    92             {
       
    93             User::LeaveIfError(fs.DriveToChar(driveNumber, driveLetter));
       
    94             filePath->Des().Zero();
       
    95             filePath->Des().Append(driveLetter);
       
    96             filePath->Des().Append(KRscPath);
       
    97             filePath->Des().Append(aFile);
       
    98 
       
    99             if (BaflUtils::FileExists(fs,*filePath))
       
   100                 {
       
   101                 return filePath;
       
   102                 }
       
   103             }
       
   104         if (driveNumber == EDriveZ)
       
   105         break;
       
   106         }
       
   107 
       
   108     User::Leave(KErrNotFound);
       
   109     return filePath;
       
   110     }
       
   111 
       
   112 // ---------------------------------------------------------------------------
       
   113 // 
       
   114 // ---------------------------------------------------------------------------
       
   115 //      
       
   116 EXPORT_C HBufC* HnUtils::LocateNearestLanguageFileLC( const TDesC& aFile )
    78 EXPORT_C HBufC* HnUtils::LocateNearestLanguageFileLC( const TDesC& aFile )
   117     {
    79     {
   118     _LIT( KExtRSC, ".r");
    80     _LIT( KExtRSC, ".r");
   119     if (aFile.Find( KExtRSC ) == (aFile.Length() - 4) )
    81     if (aFile.Find( KExtRSC ) == (aFile.Length() - 4) )
   120         {
    82         {
   121         HBufC* filePath = HBufC::NewLC(KMaxName);
    83         HBufC* filePath = HBufC::NewLC(KMaxName);
   122         RFs& fs = CEikonEnv::Static()->FsSession();
    84         RFs& fs = CEikonEnv::Static()->FsSession();
   123         TDriveList driveList;
    85         TDriveList driveList;
   124         TChar driveLetter;
    86         TChar driveLetter;
   125         TInt driveNumber=EDriveY;
    87         //locate resources only on Z drive for foldersuite
   126         User::LeaveIfError(fs.DriveList(driveList));
    88         //no need to scan all drives
       
    89         TInt driveNumber=EDriveZ;
   127         TFileName file;
    90         TFileName file;
   128         for(; driveNumber>=EDriveA-1; driveNumber-- )
    91         User::LeaveIfError(fs.DriveToChar(driveNumber, driveLetter));
       
    92         filePath->Des().Zero();
       
    93         filePath->Des().Append(driveLetter);
       
    94         filePath->Des().Append(KRscPath);
       
    95         filePath->Des().Append(aFile);
       
    96 
       
    97         file = *filePath;
       
    98         BaflUtils::NearestLanguageFile( fs, file);
       
    99         if( BaflUtils::FileExists( fs, file))
   129             {
   100             {
   130             if (driveNumber==EDriveA-1)
   101             CleanupStack::PopAndDestroy(filePath);
   131             driveNumber = EDriveZ;
   102             return file.AllocLC();
   132             if (driveList[driveNumber])
       
   133                 {
       
   134                 User::LeaveIfError(fs.DriveToChar(driveNumber, driveLetter));
       
   135                 filePath->Des().Zero();
       
   136                 filePath->Des().Append(driveLetter);
       
   137                 filePath->Des().Append(KRscPath);
       
   138                 filePath->Des().Append(aFile);
       
   139     
       
   140                 file = *filePath;
       
   141                 BaflUtils::NearestLanguageFile( fs, file);
       
   142                 if( BaflUtils::FileExists( fs, file))
       
   143                     {
       
   144                     CleanupStack::PopAndDestroy(filePath);    
       
   145                     return file.AllocLC();
       
   146                     }
       
   147                 }
       
   148             if (driveNumber == EDriveZ)
       
   149             break;
       
   150             }
   103             }
   151         CleanupStack::PopAndDestroy(filePath);
   104         CleanupStack::PopAndDestroy(filePath);
   152         }
   105         }
   153     return KNullDesC().AllocLC();
   106     return KNullDesC().AllocLC();
   154     }
   107     }