nsIPrefMigration *pPrefMigrator = nsnull;
nsCOMPtr <nsIPrefMigration> pPrefMigrator;
NS_IMETHODIMP nsProfile::MigrateProfile(const char* profileName){	nsresult rv = NS_OK;#ifdef XP_PC#if defined(DEBUG_profile)	printf("Inside Migrate Profile routine.\n" );#endif	nsFileSpec oldProfDir;	nsFileSpec newProfDir;	GetProfileDir(profileName, &oldProfDir);	// Create new profile dir path	nsIFileLocator* locator = nsnull;		// Get the new directory path the migrated profile to reside.	rv = nsServiceManager::GetService(kFileLocatorCID, nsIFileLocator::GetIID(), (nsISupports**)&locator);		if (NS_FAILED(rv) || !locator)	{	      return NS_ERROR_FAILURE;	}    // Get current profile, make the new one a sibling...	nsIFileSpec* newSpec = NS_LocateFileOrDirectory(        nsSpecialFileSpec::App_DefaultUserProfileRoot50);	if (!newSpec)	     return NS_ERROR_FAILURE;    newSpec->GetFileSpec(&newProfDir);	NS_RELEASE(newSpec);	newProfDir += profileName;	// Call migration service to do the work.	nsIPrefMigration *pPrefMigrator = nsnull;	rv = nsComponentManager::CreateInstance(kPrefMigration_CID,                                           nsnull,                                           kIPrefMigration_IID,                                           (void**) &pPrefMigrator); 	if (NS_SUCCEEDED(rv)) 	{ 		pPrefMigrator->ProcessPrefs((char *)oldProfDir.GetCString(),                                 (char *)newProfDir.GetCString(),                                 &rv); 	} 	if (NS_FAILED(rv))	     return NS_ERROR_FAILURE;	//unmark migrate flag	if (NS_SUCCEEDED(rv))	{		// Check result.		if ( m_reg != nsnull ) 		{			// Latch onto the registry object.			NS_ADDREF(m_reg);	        // Open the registry.		    rv = m_reg->Open();			if (NS_SUCCEEDED(rv))			{				nsIRegistry::Key key;				rv = m_reg->GetSubtree(nsIRegistry::Common, "Profiles", &key);				if (NS_SUCCEEDED(rv))				{			        nsIRegistry::Key newKey;					rv = m_reg->GetSubtree(key, profileName, &newKey);					if (NS_SUCCEEDED(rv))					{				        rv = m_reg->SetString( newKey, "migrated", "yes");						if (NS_SUCCEEDED(rv))						{							rv = m_reg->SetString(key, "CurrentProfile", profileName);																				if (NS_FAILED(rv))							{								#if defined(DEBUG_profile)									printf("Profiles : Couldn't set CurrentProfile Name.\n");								#endif					        }						}						else						{							#if defined(DEBUG_profile)								printf("Profiles : Couldn't set migrate flag.\n");							#endif						}						SetProfileDir(profileName, newProfDir);					}					else					{						#if defined(DEBUG_profile)							printf("Profiles : Couldn't get profileName subtree.\n");						#endif					}				}				else				{					#if defined(DEBUG_profile)						printf("Registry : Couldn't get Profiles subtree.\n");					#endif				}				m_reg->Close();			}			else			{					#if defined(DEBUG_profile)					printf("Couldn't open registry.\n");				#endif			}		}	}#endif	return rv;}