nsCOMPtr <nsIFileSpec> defaultRoot; rv = locator->GetFileLocation( nsSpecialFileSpec::App_DefaultUserProfileRoot50, getter_AddRefs(defaultRoot));
nsIFileSpec* horribleCOMDirSpecThing; rv = locator->GetFileLocation(nsSpecialFileSpec::App_DefaultUserProfileRoot50, &horribleCOMDirSpecThing);
nsProfile::CreateNewProfile(const PRUnichar* profileName,                             const PRUnichar* nativeProfileDir,                            const PRUnichar* langcode,                            PRBool useExistingDir){    NS_ENSURE_ARG_POINTER(profileName);       nsresult rv = NS_OK;#if defined(DEBUG_profile)    {      printf("ProfileManager : CreateNewProfile\n");      nsCAutoString temp1; temp1.AssignWithConversion(profileName);      printf("Profile Name: %s\n", NS_STATIC_CAST(const char*, temp1));      nsCAutoString temp2; temp2.AssignWithConversion(nativeProfileDir);      printf("Profile Dir: %s\n", NS_STATIC_CAST(const char*, temp2));    }#endif    NS_WITH_SERVICE(nsIFileLocator, locator, kFileLocatorCID, &rv);    if (NS_FAILED(rv) || !locator)        return NS_ERROR_FAILURE;    if (!profileName) return NS_ERROR_FAILURE;    nsFileSpec dirSpec;        if (!nativeProfileDir || !*nativeProfileDir)    {        // They didn't specify a directory path...        nsCOMPtr <nsIFileSpec> defaultRoot;        rv = locator->GetFileLocation(                         nsSpecialFileSpec::App_DefaultUserProfileRoot50,                          getter_AddRefs(defaultRoot));                if (NS_FAILED(rv) || !defaultRoot)            return NS_ERROR_FAILURE;        defaultRoot->GetFileSpec(&dirSpec);        if (!dirSpec.Exists())            dirSpec.CreateDirectory();        // append profile name        dirSpec += profileName;        // Make profile directory unique only when the user         // decides to not use an already existing profile directory        if (!useExistingDir)            dirSpec.MakeUnique();    }    else {        dirSpec = nativeProfileDir;        // this prevents people from choosing there profile directory        // or another directory, and remove it when they delete the profile.        // append profile name        dirSpec += profileName;        // Make profile directory unique only when the user         // decides to not use an already existing profile directory        if (!useExistingDir)            dirSpec.MakeUnique();    }#if defined(DEBUG_profile_verbose)    printf("before SetProfileDir\n");#endif    if (!dirSpec.Exists())    {        dirSpec.CreateDirectory();        useExistingDir = PR_FALSE;    }    // Set the directory value and add the entry to the registry tree.    // Creates required user directories.    rv = SetProfileDir(profileName, dirSpec);#if defined(DEBUG_profile_verbose)    printf("after SetProfileDir\n");#endif    // Get profile defaults folder..    nsCOMPtr <nsIFileSpec> profDefaultsDir;    rv = locator->GetFileLocation(                     nsSpecialFileSpec::App_ProfileDefaultsFolder50_nloc,                      getter_AddRefs(profDefaultsDir));            if (NS_FAILED(rv) || !profDefaultsDir)    {        return NS_ERROR_FAILURE;    }    nsFileSpec defaultsDirSpec;    profDefaultsDir->GetFileSpec(&defaultsDirSpec);    if (langcode) {        // caller prefers locale subdir        nsFileSpec tmpdir;         tmpdir = defaultsDirSpec;        tmpdir += langcode;        if (tmpdir.Exists())            defaultsDirSpec = tmpdir;    }    // Copy contents from defaults folder.    if (defaultsDirSpec.Exists() && (!useExistingDir))    {        defaultsDirSpec.RecursiveCopy(dirSpec);    }    gProfileDataAccess->mNumProfiles++;    gProfileDataAccess->mProfileDataChanged = PR_TRUE;    gProfileDataAccess->UpdateRegistry();    return NS_OK;}