filemanager/Engine/src/CFileManagerUtils.cpp
branchRCL_3
changeset 52 40fb776cbfb3
parent 42 f5c50b8af68c
equal deleted inserted replaced
45:6a0ceb387ac7 52:40fb776cbfb3
   883 //
   883 //
   884 HBufC* CFileManagerUtils::GetFormattedDriveNameLC(
   884 HBufC* CFileManagerUtils::GetFormattedDriveNameLC(
   885         const TInt aDrive,
   885         const TInt aDrive,
   886         const TInt aTextIdForDefaultName,
   886         const TInt aTextIdForDefaultName,
   887         const TInt aTextIdForName ) const
   887         const TInt aTextIdForName ) const
   888     {  
   888     {
   889     // get drive letter and drive name
       
   890     TUint driveStatus( 0 );
   889     TUint driveStatus( 0 );
       
   890     HBufC* ret = NULL;
   891     CDesCArray* array = GetDriveNameArrayLC( aDrive, driveStatus );
   891     CDesCArray* array = GetDriveNameArrayLC( aDrive, driveStatus );
   892     
       
   893     // get the format string for drive name
       
   894     HBufC* ret = NULL; 
       
   895     if ( aTextIdForName && array->MdcaCount() > 1 )
   892     if ( aTextIdForName && array->MdcaCount() > 1 )
   896         {
   893         {
   897         // named resource is available
   894         ret = StringLoader::LoadL(
   898         // resource needs two paraments
   895             aTextIdForName,
   899         ret = StringLoader::LoadL( aTextIdForName,*array );
   896             *array );
   900         }
   897         }
   901     // default resource is available
       
   902     else if ( aTextIdForDefaultName )
   898     else if ( aTextIdForDefaultName )
   903         {
   899         {
   904         // USB memory 
   900 			if( driveStatus & DriveInfo::EDriveUsbMemory )
   905         if ( driveStatus & DriveInfo::EDriveUsbMemory )
   901 				{
   906             {
   902 				CDesCArray* usbLetterName = new ( ELeave ) CDesCArrayFlat( KDriveNameArrayLen );
   907             // alloc array for usb letter name and drive name
   903 				CleanupStack::PushL( usbLetterName );
   908             CDesCArray* usbLetterAndName = new ( ELeave ) CDesCArrayFlat( KDriveNameArrayLen );
   904 				
   909             CleanupStack::PushL( usbLetterAndName );
   905 				TPtrC16 driveletter=array->MdcaPoint( KDriveLetterIndex );
   910             
   906 				usbLetterName->AppendL( driveletter );							
   911             // append driver letter 
   907 				HBufC* usbDriveDefaultName = NULL;			
   912             TPtrC16 driveLetter = array->MdcaPoint( KDriveLetterIndex );
   908 				if(array->MdcaCount() > 1 )
   913             usbLetterAndName->AppendL( driveLetter );
   909 					{
   914             
   910 					TPtrC16 drivename=array->MdcaPoint( KDriveNameIndex );
   915             // USB is already named, just append it 
   911 					usbLetterName->AppendL( drivename );
   916             if ( array->MdcaCount() > 1 )
   912 					}
   917                 {
   913 				else
   918                 TPtrC16 drivename=array->MdcaPoint( KDriveNameIndex );
   914 					{
   919                 usbLetterAndName->AppendL( drivename );
   915 				    usbDriveDefaultName = StringLoader::LoadLC( R_QTN_FMGR_USB_MEMORY_DEFAULT_NAME );
   920                 }
   916 				    TPtrC16 drivename = usbDriveDefaultName->Des();
   921             // USB is still not named,append default name
   917 				    usbLetterName->AppendL( drivename );
   922             else
   918 					}
   923                 {
   919 				
   924                 HBufC* usbDefaultName = StringLoader::LoadLC( R_QTN_FMGR_USB_MEMORY_DEFAULT_NAME );
   920 				
   925                 usbLetterAndName->AppendL( *usbDefaultName );
   921 				ret = StringLoader::LoadL(
   926                 CleanupStack::PopAndDestroy( usbDefaultName );
   922 				aTextIdForDefaultName,*usbLetterName );
   927                 }
   923 	
   928             ret = StringLoader::LoadL( aTextIdForDefaultName,*usbLetterAndName );
   924 				CleanupStack::PopAndDestroy( usbLetterName );
   929             // pop and destory the array for usb letter name and drive name
   925 				if ( usbDriveDefaultName )
   930             CleanupStack::PopAndDestroy( usbLetterAndName );
   926 				    {
   931             }
   927 				    CleanupStack::PopAndDestroy( usbDriveDefaultName );
   932         // other drives
   928 				    }
   933         else
   929 			    }
   934             {
   930 		    else
   935             ret = StringLoader::LoadL( aTextIdForDefaultName, array->MdcaPoint( KDriveLetterIndex ) );
   931 			    {
   936             }
   932 			    ret = StringLoader::LoadL(aTextIdForDefaultName, array->MdcaPoint(
   937         }
   933 					KDriveLetterIndex));
   938     // drive name is available
   934             	}
       
   935         }
   939     else if (  array->MdcaCount() > 1 )
   936     else if (  array->MdcaCount() > 1 )
   940         {
   937         {
   941         ret = array->MdcaPoint( KDriveNameIndex ).AllocL();
   938         ret = array->MdcaPoint( KDriveNameIndex ).AllocL();
   942         }
   939         }
   943     // others
       
   944     else
   940     else
   945         {
   941         {
   946         User::Leave( KErrNotFound );
   942         User::Leave( KErrNotFound );
   947         }
   943         }
   948     CleanupStack::PopAndDestroy( array );
   944     CleanupStack::PopAndDestroy( array );