g_numOldProfiles++;
mNumOldProfiles++; } #endif   if (mNumOldProfiles > 0) { rv = UpdateMozProfileRegistry(); if (NS_FAILED(rv)) return rv;
NS_IMETHODIMP nsProfile::MigrateProfileInfo(){	nsresult rv = NS_OK;#if defined(XP_PC) || defined(XP_MAC)#if defined(DEBUG_profile)    printf("Entered MigrateProfileInfo.\n");#endif	char oldRegFile[_MAX_LENGTH] = {'\0'};    // Check result.    if ( m_reg != nsnull ) 	{		/***********************		Get the right registry file. Ideally from File Locations.		File Locations is yet to implement this service.	                NS_WITH_SERVICE(nsIFileLocator, locator, kFileLocatorCID, &rv);		if (NS_FAILED(rv) || !locator) return NS_ERROR_FAILURE;		nsFileSpec oldAppRegistry;			// Get current profile, make the new one a sibling...		rv = locator->GetFileLocation(nsSpecialFileSpec::App_Registry50, &oldAppRegistry);		nsServiceManager::ReleaseService(kFileLocatorCID, locator);		if (NS_FAILED(rv))			 return NS_ERROR_FAILURE;		oldAppRegistry.SetLeafName(OLD_WINREG);        #error DONT_USE_GETCSTRING		rv = m_reg->Open(oldAppRegistryGetCString());		************************/#ifdef XP_PC		// Registry file has been traditionally stored in the windows directory (XP_PC).		nsSpecialSystemDirectory systemDir(nsSpecialSystemDirectory::Win_WindowsDirectory);		// Append the name of the old registry to the path obtained.		PL_strcpy(oldRegFile, systemDir.GetNativePathCString());		PL_strcat(oldRegFile, oldWinReg);#endif#ifdef XP_MAC		nsSpecialSystemDirectory *regLocation = NULL;        regLocation = new nsSpecialSystemDirectory(nsSpecialSystemDirectory::Mac_SystemDirectory);		// Append the name of the old registry to the path obtained.		*regLocation += "Preferences";		*regLocation += oldMacReg;		        PL_strcpy(oldRegFile, regLocation->GetNativePathCString());#endif		rv = m_reg->Open(oldRegFile);		// Enumerate 4x tree and create an array of that information.		if (NS_SUCCEEDED(rv))		{            // Enumerate all subkeys (immediately) under the given node.            nsCOMPtr<nsIEnumerator> enumKeys;            if (NS_SUCCEEDED(rv)) 			{            				rv = m_reg->EnumerateSubtrees(nsIRegistry::Users,                                              getter_AddRefs(enumKeys));                if (NS_SUCCEEDED(rv)) 				{                					rv = enumKeys->First();                    					// Enumerate subkeys till done.                    while( NS_SUCCEEDED( rv ) && (NS_OK != enumKeys->IsDone()) )                     {						nsCOMPtr<nsISupports> base;						rv = enumKeys->CurrentItem(getter_AddRefs(base));						if (NS_SUCCEEDED(rv)) 						{	                        // Get specific interface.		                    nsIRegistryNode *node;			                nsIID nodeIID = NS_IREGISTRYNODE_IID;				            rv = base->QueryInterface( nodeIID, (void**)&node );					        						    // Get Node details.							if (NS_SUCCEEDED(rv)) 							{	                            // Get node name.		                        nsXPIDLCString profile;                                rv = node->GetName(getter_Copies(profile));#if defined(DEBUG_profile)                                printf("oldProflie = %s\n", profile);#endif								nsIRegistry::Key key;																							rv = m_reg->GetSubtree(nsIRegistry::Users, profile, &key);								if (NS_SUCCEEDED(rv)) 								{									PL_strcpy(gOldProfiles[g_numOldProfiles], nsUnescape(profile));								}                                nsXPIDLCString profLoc;																rv = m_reg->GetString( key, "ProfileLocation", getter_Copies(profLoc));#if defined(DEBUG_profile)                                printf("oldProflie Location = %s\n", profLoc);#endif															if (NS_SUCCEEDED(rv)) 								{									PL_strcpy(gOldProfLocations[g_numOldProfiles], profLoc);									g_numOldProfiles++;								}                            }						}						    rv = enumKeys->Next();					}				}            }			m_reg->Close();						if (g_numOldProfiles > 0)			{				UpdateMozProfileRegistry();			}		}	}#else    char *unixProfileName = PR_GetEnv(PROFILE_NAME_ENVIRONMENT_VARIABLE);    char *unixProfileDirectory = PR_GetEnv(PROFILE_HOME_ENVIRONMENT_VARIABLE);	    if (!unixProfileName || !unixProfileDirectory || (PL_strlen(unixProfileName) == 0) || (PL_strlen(unixProfileDirectory) == 0)) {	    unixProfileName = PR_GetEnv(USER_ENVIRONMENT_VARIABLE);	    unixProfileDirectory = PR_GetEnv(HOME_ENVIRONMENT_VARIABLE);    }    if (unixProfileName && unixProfileDirectory) {	PL_strcpy(gOldProfiles[g_numOldProfiles], nsUnescape(unixProfileName));	PL_strcpy(gOldProfLocations[g_numOldProfiles], unixProfileDirectory);	PL_strcat(gOldProfLocations[g_numOldProfiles], "/.netscape");#ifdef DEBUG_profile	printf("unix profile is %s, unix profile dir is %s\n",gOldProfiles[g_numOldProfiles],gOldProfLocations[g_numOldProfiles]);#endif	g_numOldProfiles++;    }    if (g_numOldProfiles > 0) {        UpdateMozProfileRegistry();    }#endif /* XP_PC || XP_MAC */	return rv;}