TBool CPMRfsPlugin::IsMMCFormatFlagEnabledL() { RDEBUG("CPMRfsPlugin::IsMMCFormatFlagEnabledL()"); RFs rfs; User::LeaveIfError( rfs.Connect() ); CleanupClosePushL( rfs ); #ifndef RD_MULTIPLE_DRIVE TFileName fullPath; fullPath.Append( _L("e") ); fullPath.Append( MDriveColon ); fullPath.Append( KDMUtilServerPrivatePath ); fullPath.Append( KMMCEraseFlagFileName ); RFile file; TInt err = file.Open( rfs, fullPath, EFileRead ); file.Close(); CleanupStack::PopAndDestroy( &rfs ); if( err == KErrNone ) { RDEBUG("CPMRfsPlugin::IsMMCFormatFlagEnabled() - returned: ETrue"); return ETrue; } RDEBUG_2("CPMRfsPlugin::IsMMCFormatFlagEnabled() - returned: EFalse: %d)", err); return EFalse; #else TDriveList driveList; TInt driveCount; TBool fileReplace = EFalse; TInt err = KErrNone; //Get all removeable drive, both physically and logically User::LeaveIfError(DriveInfo::GetUserVisibleDrives( rfs, driveList, driveCount, KDriveAttRemovable )); TInt max(driveList.Length()); RFileWriteStream file; for(TInt i=0; i<max;++i) { if (driveList[i]) { TUint status; DriveInfo::GetDriveStatus(rfs, i, status); //To make sure the drive is physically removeable not logically removeable //need to format internal mass memory also. So no need to check the below condition //if (status & DriveInfo::EDriveRemovable) { TChar driveLetter; rfs.DriveToChar(i,driveLetter); TFileName fullPath; fullPath.Append( driveLetter ); fullPath.Append( MDriveColon ); fullPath.Append( KDMUtilServerPrivatePath ); fullPath.Append( KMMCEraseFlagFileName ); RFile flagfile; err = flagfile.Open( rfs, fullPath, EFileRead ); flagfile.Close(); if( err == KErrNone ) { if (!fileReplace) { User::LeaveIfError(file.Temp(rfs, _L("C:\\"),iFileName, EFileWrite)); file.WriteInt16L(65279); CleanupClosePushL(file); fileReplace = ETrue; RDEBUG("CPMRfsPlugin::IsMMCFormatFlagEnabled() - File created on private path"); } file.WriteL(_L("FORMAT")); file.WriteL(_L(" ")); TBuf<4> DriveLetterBuf; DriveLetterBuf.Append(driveLetter); file.WriteL(DriveLetterBuf); file.WriteL(_L(":")); file.WriteL(_L("\r\n")); } } } } if (fileReplace) { file.CommitL(); CleanupStack::PopAndDestroy(); // pop file } CleanupStack::PopAndDestroy( &rfs ); if (fileReplace) { RDEBUG("CPMRfsPlugin::IsMMCFormatFlagEnabled() - returned: ETrue:"); return ETrue; } else { RDEBUG_2("CPMRfsPlugin::IsMMCFormatFlagEnabled() - returned: EFalse: %d)", err); return EFalse; } #endif //RD_MULTIPLE_DRIVE }