newProfileDir.MakeUnique();  if (newProfileDir.Exists()) { #ifdef DEBUG_profile printf("directory already exists\n"); #endif return NS_ERROR_FAILURE; }
NS_IMETHODIMP nsProfile::CloneProfile(const char* newProfile){    nsresult rv = NS_OK;#if defined(DEBUG_profile)    printf("ProfileManager : CloneProfile\n");#endif	nsFileSpec currProfileDir;	nsFileSpec newProfileDir;	GetCurrentProfileDir(&currProfileDir);	if (currProfileDir.Exists())	{		NS_WITH_SERVICE(nsIFileLocator, locator, kFileLocatorCID, &rv);		if (NS_FAILED(rv) || !locator) return NS_ERROR_FAILURE;	    	nsCOMPtr <nsIFileSpec> dirSpec;        	rv = locator->GetFileLocation(nsSpecialFileSpec::App_DefaultUserProfileRoot50, getter_AddRefs(dirSpec));        		if (NS_FAILED(rv) || !dirSpec)			return NS_ERROR_FAILURE;		//Append profile name to form a directory name	    	dirSpec->GetFileSpec(&newProfileDir);		// TODO:		// hash profileName  (will MakeUnique do that for us?)		// don't allow special characters (like ..)		// make acceptable length (will MakeUnique do that for us?)		newProfileDir += newProfile;		newProfileDir.MakeUnique();		if (newProfileDir.Exists()) {#ifdef DEBUG_profile			printf("directory already exists\n");#endif			return NS_ERROR_FAILURE;		}		currProfileDir.RecursiveCopy(newProfileDir);				rv = SetProfileDir(newProfile, newProfileDir);	}#if defined(DEBUG_profile)	if (NS_SUCCEEDED(rv))		printf("ProfileManager : Cloned CurrentProfile to new Profile ->%s<-\n", newProfile);#endif	return rv;}