rv = mailDir->AppendRelativeUnixPath(hostname); PR_FREEIF(hostname);
rv = mailDir->AppendRelativeUnixPath(hostAndPort); PR_FREEIF(hostAndPort);
nsMsgAccountManager::MigratePopAccount(nsIMsgIdentity *identity){  nsresult rv;    nsCOMPtr<nsIMsgAccount> account;  nsCOMPtr<nsIMsgIncomingServer> server;  rv = CreateAccount(getter_AddRefs(account));  if (NS_FAILED(rv)) return rv;  rv = CreateIncomingServer("pop3", getter_AddRefs(server));  if (NS_FAILED(rv)) return rv;  // create the identity  nsCOMPtr<nsIMsgIdentity> copied_identity;  rv = CreateIdentity(getter_AddRefs(copied_identity));  if (NS_FAILED(rv)) return rv;  // make this new identity to copy of the identity  // that we created out of the 4.x prefs  rv = CopyIdentity(identity,copied_identity);  if (NS_FAILED(rv)) return rv;  rv = SetMailCcAndFccValues(copied_identity);  if (NS_FAILED(rv)) return rv;  // hook them together  account->SetIncomingServer(server);  account->AddIdentity(copied_identity);    // now upgrade all the prefs  nsCOMPtr <nsIFileSpec> mailDir;  nsFileSpec dir;  PRBool dirExists;  server->SetType("pop3");  char *hostname=nsnull;  rv = m_prefs->CopyCharPref(PREF_4X_NETWORK_HOSTS_POP_SERVER, &hostname);  if (NS_SUCCEEDED(rv)) {    server->SetHostName(hostname);  }  else {    return rv;  }  rv = MigrateOldPopPrefs(server, hostname);  if (NS_FAILED(rv)) return rv;  // if they used -installer, this pref will point to where their files got copied  rv = m_prefs->GetFilePref(PREF_MAIL_DIRECTORY, getter_AddRefs(mailDir));  // create the directory structure for old 4.x pop mail  // under <profile dir>/Mail/<pop host name> or  // <"mail.directory" pref>/<pop host name>  //  // if the "mail.directory" pref is set, use that.  if (NS_FAILED(rv)) {    // we wan't <profile>/Mail    NS_WITH_SERVICE(nsIFileLocator, locator, kFileLocatorCID, &rv);    if (NS_FAILED(rv)) return rv;    rv = locator->GetFileLocation(nsSpecialFileSpec::App_MailDirectory50, getter_AddRefs(mailDir));    if (NS_FAILED(rv)) return rv;  }  // set the default local path for "pop3"  rv = server->SetDefaultLocalPath(mailDir);  if (NS_FAILED(rv)) return rv;  rv = mailDir->Exists(&dirExists);  if (!dirExists) {    mailDir->CreateDir();  }  // we want .../Mail/<hostname>, not .../Mail  rv = mailDir->AppendRelativeUnixPath(hostname);  PR_FREEIF(hostname);  if (NS_FAILED(rv)) return rv;    // set the local path for this "pop3" server  rv = server->SetLocalPath(mailDir);  if (NS_FAILED(rv)) return rv;      rv = mailDir->Exists(&dirExists);  if (!dirExists) {    mailDir->CreateDir();  }      return NS_OK;}