nsSpecialSystemDirectory systemDir(nsSpecialSystemDirectory::Win_WindowsDirectory);   PL_strcpy(oldRegFile, systemDir.GetNativePathCString()); PL_strcat(oldRegFile, OLD_REGISTRY_FILE_NAME); #else  nsSpecialSystemDirectory *regLocation = NULL;  regLocation = new nsSpecialSystemDirectory(nsSpecialSystemDirectory::Mac_SystemDirectory);   *regLocation += "Preferences"; *regLocation += OLD_REGISTRY_FILE_NAME;  PL_strcpy(oldRegFile, regLocation->GetNativePathCString()); #endif
nsSpecialSystemDirectory systemDir(nsSpecialSystemDirectory::Win_WindowsDirectory);
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'};#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, OLD_REGISTRY_FILE_NAME);#else /* 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 += OLD_REGISTRY_FILE_NAME;        PL_strcpy(oldRegFile, regLocation->GetNativePathCString());#endif /* XP_PC */    nsCOMPtr <nsIRegistry> oldReg;    rv = nsComponentManager::CreateInstance(kRegistryCID,                                            nsnull,                                            nsIRegistry::GetIID(),                                            getter_AddRefs(oldReg));    if (NS_FAILED(rv)) return rv;        rv = oldReg->Open(oldRegFile);    if (NS_FAILED(rv)) return rv;        // Enumerate 4x tree and create an array of that information.    // Enumerate all subkeys (immediately) under the given node.    nsCOMPtr<nsIEnumerator> enumKeys;        rv = oldReg->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.                            nsCOMPtr <nsIRegistryNode> node;                            nsIID nodeIID = NS_IREGISTRYNODE_IID;                            rv = base->QueryInterface( nodeIID, getter_AddRefs(node));                                                        // Get Node details.                            if (NS_SUCCEEDED(rv))                                 {	                            // Get node name.                                    char *profile = nsnull;                                    rv = node->GetName(&profile);                                    #if defined(DEBUG_profile)                                    printf("oldProflie = %s\n", profile);#endif                                                                        nsRegistryKey key;								                                                                        rv = oldReg->GetSubtree(nsIRegistry::Users, profile, &key);                                                                        if (NS_SUCCEEDED(rv))                                         {                                            PL_strcpy(mOldProfiles[mNumOldProfiles], nsUnescape(profile));                                        }                                                                        nsXPIDLCString profLoc;                                                                        rv = oldReg->GetString( key, "ProfileLocation", getter_Copies(profLoc));                                    #if defined(DEBUG_profile)                                    printf("oldProflie Location = %s\n", profLoc);#endif                                                                        if (NS_SUCCEEDED(rv))                                         {                                            PL_strcpy(mOldProfLocations[mNumOldProfiles], profLoc);                                            mNumOldProfiles++;                                        }                                                                    }                        }	                    rv = enumKeys->Next();                }        }    oldReg->Close();#else    /* XP_UNIX */    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(mOldProfiles[mNumOldProfiles], nsUnescape(unixProfileName));        PL_strcpy(mOldProfLocations[mNumOldProfiles], unixProfileDirectory);        PL_strcat(mOldProfLocations[mNumOldProfiles], "/.netscape");#ifdef DEBUG_profile        printf("unix profile is %s, unix profile dir is %s\n",mOldProfiles[mNumOldProfiles],mOldProfLocations[mNumOldProfiles]);#endif        mNumOldProfiles++;    }#endif /* XP_PC || XP_MAC */    if (mNumOldProfiles > 0) {        rv = UpdateMozProfileRegistry();	if (NS_FAILED(rv)) return rv;    }	return rv;}