rv = ForgetCurrentProfile(); if (NS_FAILED(rv)) return rv;   if (canDeleteFiles) { nsFileSpec profileDirSpec;  rv = GetProfileDir(profileName, &profileDirSpec); if (NS_FAILED(rv)) return rv;  rv = DeleteUserDirectories(profileDirSpec); if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv)) { #if defined(DEBUG_profile) printf("Error opening Registry.\n" ); #endif return rv; }  #if defined(DEBUG_profile) printf("Registry opened OK.\n" ); #endif  nsIRegistry::Key key;  rv = m_reg->GetSubtree(nsIRegistry::Common, "Profiles", &key);  if (NS_FAILED(rv)) { #if defined(DEBUG_profile) printf("Can't obtain subtree Profiles.\n" ); #endif  return rv; }   rv = m_reg->RemoveSubtree(key, profileName);  if (NS_FAILED(rv)) return rv; else { #if defined(DEBUG_profile) printf("DeleteProfile : deleted profile -> %s <-\n", profileName); #endif }       if (!renameCurrProfile) { char *oldCurrProfile = nsnull; char *newCurrProfile = nsnull;  GetCurrentProfile(&oldCurrProfile);  if (PL_strcmp(profileName, oldCurrProfile) == 0) { GetFirstProfile(&newCurrProfile);  #if defined(DEBUG_profile) printf("DeleteProfile : Old Current profile -> %s <-\n", oldCurrProfile); printf("DeleteProfile : New Current profile -> %s <-\n", newCurrProfile); #endif  rv = m_reg->SetString(key, "CurrentProfile", newCurrProfile);  if (NS_FAILED(rv)) { #if defined(DEBUG_profile) printf("Did not take nsnull successfully\n"); #endif } } } m_reg->Close();
NS_IMETHODIMP nsProfile::DeleteProfile(const char* profileName, PRBool canDeleteFiles){    nsresult rv = NS_OK; #if defined(DEBUG_profile)    printf("ProfileManager : DeleteProfile(%s,%s)\n", profileName, canDeleteFiles?"true":"false");#endif        rv = OpenRegistry();    if (NS_FAILED(rv)) return rv;        nsRegistryKey key;        rv = m_reg->GetSubtree(nsIRegistry::Common, REGISTRY_PROFILE_SUBTREE_STRING, &key);    if (NS_FAILED(rv)) return rv;#if defined(DEBUG_profile)     printf("DeleteProfile : deleted profile -> %s <-\n", profileName);#endif    rv = ForgetCurrentProfile();    if (NS_FAILED(rv)) return rv;        // If user asks for it, delete profile directory    if (canDeleteFiles) {        nsFileSpec profileDirSpec;                rv = GetProfileDir(profileName, &profileDirSpec);        if (NS_FAILED(rv)) return rv;                rv = DeleteUserDirectories(profileDirSpec);        if (NS_FAILED(rv)) return rv;    }    // Remove the subtree from the registry.    rv = m_reg->RemoveSubtree(key, profileName);    if (NS_FAILED(rv)) return rv;        return rv;}