nsresult rv = NS_OK;  #if defined(DEBUG_profile) printf("ProfileManager : CreateNewProfile\n"); printf("ProfileManagerData*** : %s\n", charData); #endif  nsIFileLocator* locator = nsnull;  rv = nsServiceManager::GetService(kFileLocatorCID, nsIFileLocator::GetIID(), (nsISupports**)&locator);  if (NS_FAILED(rv) || !locator) return NS_ERROR_FAILURE;  nsString data(charData);   SetDataArray(data);  char* dirName = GetValue("ProfileDir"); char* unescapedProfileName = GetValue("ProfileName");  if (!unescapedProfileName || !*unescapedProfileName) return NS_ERROR_FAILURE;    char* profileName = nsEscape(unescapedProfileName, url_Path);  nsFileSpec dirSpec(dirName);  if (!dirName || !*dirName) {   nsIFileSpec* horribleCOMDirSpecThing; rv = locator->GetFileLocation(nsSpecialFileSpec::App_DefaultUserProfileRoot50, &horribleCOMDirSpecThing);  if (NS_FAILED(rv) || !horribleCOMDirSpecThing) return NS_ERROR_FAILURE;   horribleCOMDirSpecThing->GetFileSpec(&dirSpec); NS_RELEASE(horribleCOMDirSpecThing);  dirSpec += profileName; }  #if defined(DEBUG_profile) printf("before SetProfileDir\n"); #endif    rv = SetProfileDir(unescapedProfileName, dirSpec);  PR_DELETE(unescapedProfileName);  #if defined(DEBUG_profile) printf("after SetProfileDir\n"); #endif  if (NS_FAILED(rv)) return rv;   nsIFileSpec* profDefaultsDir; rv = locator->GetFileLocation(nsSpecialFileSpec::App_ProfileDefaultsFolder50, &profDefaultsDir);  if (NS_FAILED(rv) || !profDefaultsDir) return NS_ERROR_FAILURE;  nsFileSpec defaultsDirSpec;  profDefaultsDir->GetFileSpec(&defaultsDirSpec); NS_RELEASE(profDefaultsDir);   if (defaultsDirSpec.Exists()) { defaultsDirSpec.RecursiveCopy(dirSpec); }  nsServiceManager::ReleaseService(kFileLocatorCID, locator);  if (dirName) { PR_DELETE(dirName); } delete [] profileName;  return NS_OK;
return CreateNewProfileWithLocales(profileName,nativeProfileDir,langcode,nsnull,useExistingDir);
NS_IMETHODIMP nsProfile::CreateNewProfile(char* charData){	nsresult rv = NS_OK;#if defined(DEBUG_profile)    printf("ProfileManager : CreateNewProfile\n");    printf("ProfileManagerData*** : %s\n", charData);#endif	nsIFileLocator* locator = nsnull;			rv = nsServiceManager::GetService(kFileLocatorCID, nsIFileLocator::GetIID(), (nsISupports**)&locator);	if (NS_FAILED(rv) || !locator)		return NS_ERROR_FAILURE;    nsString data(charData);    	// Set the gathered info into an array	SetDataArray(data);    	char* dirName = GetValue("ProfileDir");    char* unescapedProfileName = GetValue("ProfileName");    	if (!unescapedProfileName || !*unescapedProfileName)		return NS_ERROR_FAILURE;	// Escape profile name to create a valid direrctory, 	// if directory value is not provided	char* profileName = nsEscape(unescapedProfileName, url_Path); // temp hack      	nsFileSpec dirSpec(dirName);	if (!dirName || !*dirName)    {		// They didn't type a directory path...		// Get current profile, make the new one a sibling...	    nsIFileSpec* horribleCOMDirSpecThing;        rv = locator->GetFileLocation(nsSpecialFileSpec::App_DefaultUserProfileRoot50, &horribleCOMDirSpecThing);        		if (NS_FAILED(rv) || !horribleCOMDirSpecThing)			return NS_ERROR_FAILURE;		//Append profile name to form a directory name	    horribleCOMDirSpecThing->GetFileSpec(&dirSpec);		NS_RELEASE(horribleCOMDirSpecThing);		//dirSpec.SetLeafName(profileName);		dirSpec += profileName;	}#if defined(DEBUG_profile)	printf("before SetProfileDir\n");#endif	// Set the directory value and add the entry to the registry tree.	// Creates required user directories.    rv = SetProfileDir(unescapedProfileName, dirSpec);	PR_DELETE(unescapedProfileName);#if defined(DEBUG_profile)    printf("after SetProfileDir\n");#endif    if (NS_FAILED(rv))		return rv;    // Get profile defaults folder..    nsIFileSpec* profDefaultsDir;    rv = locator->GetFileLocation(nsSpecialFileSpec::App_ProfileDefaultsFolder50, &profDefaultsDir);        	if (NS_FAILED(rv) || !profDefaultsDir)		return NS_ERROR_FAILURE;	nsFileSpec defaultsDirSpec;	profDefaultsDir->GetFileSpec(&defaultsDirSpec);	NS_RELEASE(profDefaultsDir);	// Copy contents from defaults folder.	if (defaultsDirSpec.Exists())	{		defaultsDirSpec.RecursiveCopy(dirSpec);	}	nsServiceManager::ReleaseService(kFileLocatorCID, locator);			if (dirName)	{		PR_DELETE(dirName);	}	delete [] profileName;    return NS_OK;}