aProfile->profileName     = profileName; aProfile->SetResolvedProfileDir(localFile); aProfile->isMigrated = PR_TRUE;
rv = m_reg->AddSubtree(key, profileName, &newKey);  if (NS_SUCCEEDED(rv)) {  nsFileSpec tmpDir(profileDir);
nsresult nsProfile::SetProfileDir(const PRUnichar *profileName, nsIFile *profileDir){    NS_ENSURE_ARG(profileName);    NS_ENSURE_ARG(profileDir);       nsresult rv = NS_OK;     // Need to ensure that this directory exists    PRBool exists;    rv = profileDir->Exists(&exists);    if (NS_SUCCEEDED(rv) && !exists)        rv = profileDir->Create(nsIFile::DIRECTORY_TYPE, 0775);    if (NS_FAILED(rv)) return rv;        nsCOMPtr<nsILocalFile> localFile(do_QueryInterface(profileDir));    NS_ENSURE_TRUE(localFile, NS_ERROR_FAILURE);                    ProfileStruct* aProfile = new ProfileStruct();    NS_ENSURE_TRUE(aProfile, NS_ERROR_OUT_OF_MEMORY);    aProfile->profileName     = profileName;    aProfile->SetResolvedProfileDir(localFile);    aProfile->isMigrated = PR_TRUE;    rv = CreateUserDirectories(localFile);    if (NS_FAILED(rv)) {        delete aProfile;        return rv;    }    gProfileDataAccess->SetValue(aProfile);                               gProfileDataAccess->SetCurrentProfile(profileName);        delete aProfile;    return rv;}