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