rv = gProfileDataAccess->GetValue(profileName, &aProfile); if (NS_FAILED(rv)) return rv;
if (NS_SUCCEEDED(rv)) { nsIRegistry::Key key;
NS_IMETHODIMP nsProfile::GetProfileDir(const PRUnichar *profileName, nsFileSpec* profileDir){    NS_ENSURE_ARG_POINTER(profileName);       NS_ENSURE_ARG_POINTER(profileDir);    nsresult rv = NS_OK;#if defined(DEBUG_profile)    printf("ProfileManager : GetProfileDir\n");#endif    ProfileStruct    *aProfile;    rv = gProfileDataAccess->GetValue(profileName, &aProfile);    if (NS_FAILED(rv)) return rv;	if (aProfile == nsnull)		return NS_ERROR_FAILURE;    nsCOMPtr<nsIFileSpec>spec;    rv = NS_NewFileSpec(getter_AddRefs(spec));    if (NS_FAILED(rv)) return rv;    nsCAutoString profileLocation;    profileLocation.AssignWithConversion(aProfile->profileLocation);    rv = spec->SetPersistentDescriptorString(profileLocation.GetBuffer());    if (NS_FAILED(rv)) return rv;    rv = spec->GetFileSpec(profileDir);    if (NS_FAILED(rv)) return rv;                               // Set this to be a current profile only if it is a 5.0 profile    if (aProfile->isMigrated.EqualsWithConversion(REGISTRY_YES_STRING))    {        gProfileDataAccess->SetCurrentProfile(profileName);                                          nsFileSpec tmpFileSpec(*profileDir);        if (!tmpFileSpec.Exists())         {            // Get profile defaults folder..            NS_WITH_SERVICE(nsIFileLocator, locator, kFileLocatorCID, &rv);                                                   if (NS_FAILED(rv) || !locator)                return NS_ERROR_FAILURE;                                                    nsCOMPtr <nsIFileSpec> profDefaultsDir;                        rv = locator->GetFileLocation(                             nsSpecialFileSpec::App_ProfileDefaultsFolder50,                              getter_AddRefs(profDefaultsDir));            if (NS_FAILED(rv) || !profDefaultsDir)                return NS_ERROR_FAILURE;                                                    nsFileSpec defaultsDirSpec;            profDefaultsDir->GetFileSpec(&defaultsDirSpec);            // Need a separate hack for Mac. For now app folder is the fall back on Mac.            nsFilePath(tmpFileSpec.GetNativePathCString(), PR_TRUE);                                                    // Copy contents from defaults folder.            if (defaultsDirSpec.Exists())                defaultsDirSpec.RecursiveCopy(tmpFileSpec);        }    }	delete aProfile;    return rv;}