if (currProfileDir.Exists()) { nsCOMPtr <nsIFileSpec> dirSpec; rv = locator->GetFileLocation( nsSpecialFileSpec::App_DefaultUserProfileRoot50, getter_AddRefs(dirSpec));
if (currProfileDir.Exists()) { nsIFileLocator* locator = nsnull;  rv = nsServiceManager::GetService(kFileLocatorCID, nsIFileLocator::GetIID(), (nsISupports**)&locator);  if (NS_FAILED(rv) || !locator) return NS_ERROR_FAILURE;  nsIFileSpec* dirSpec; rv = locator->GetFileLocation(nsSpecialFileSpec::App_DefaultUserProfileRoot50, &dirSpec);
NS_IMETHODIMP nsProfile::CloneProfile(const PRUnichar* newProfile){    NS_ENSURE_ARG_POINTER(newProfile);       nsresult rv = NS_OK;#if defined(DEBUG_profile)    printf("ProfileManager : CloneProfile\n");#endif    nsFileSpec currProfileDir;    nsFileSpec newProfileDir;    NS_WITH_SERVICE(nsIFileLocator, locator, kFileLocatorCID, &rv);    if (NS_FAILED(rv) || !locator) return NS_ERROR_FAILURE;    GetCurrentProfileDir(&currProfileDir);    if (currProfileDir.Exists())    {        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_verbose)    {      if (NS_SUCCEEDED(rv))      printf("ProfileManager : Cloned CurrentProfile\n");      nsCAutoString temp; temp.AssignWithConversion(newProfile);      printf("The new profile is ->%s<-\n", NS_STATIC_CAST(const char*, temp));    }#endif    gProfileDataAccess->mNumProfiles++;    gProfileDataAccess->mProfileDataChanged = PR_TRUE;    rv = locator->ForgetProfileDir();    if (NS_FAILED(rv)) return rv;      return rv;}