nsCOMPtr<nsIFile> currProfileDir; rv = GetCurrentProfileDir(getter_AddRefs(currProfileDir)); if (NS_FAILED(rv)) return rv;
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        nsCOMPtr<nsIFile> currProfileDir;    rv = GetCurrentProfileDir(getter_AddRefs(currProfileDir));    if (NS_FAILED(rv)) return rv;    PRBool exists;        rv = currProfileDir->Exists(&exists);    if (NS_SUCCEEDED(rv) && exists)    {        nsCOMPtr<nsIFile> aFile;        rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILES_ROOT_DIR, getter_AddRefs(aFile));        if (NS_FAILED(rv)) return rv;        nsCOMPtr<nsILocalFile> destDir(do_QueryInterface(aFile, &rv));        if (NS_FAILED(rv)) return rv;        destDir->AppendRelativePath(nsDependentString(newProfile));        // Find a unique name in the dest dir        rv = destDir->CreateUnique(nsIFile::DIRECTORY_TYPE, 0700);        if (NS_FAILED(rv)) return rv;                rv = RecursiveCopy(currProfileDir, destDir);        if (NS_FAILED(rv)) return rv;                   rv = SetProfileDir(newProfile, destDir);    }#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", temp.get());    }#endif    gProfileDataAccess->mProfileDataChanged = PR_TRUE;    return rv;}