pathResult += folder;
if (folder != "") pathResult += folder;
nsLocalURI2Path(const char* rootURI, const char* uriStr,                nsFileSpec& pathResult){  nsresult rv;  nsCOMPtr<nsIMsgIncomingServer> server;    nsAutoString sep;  sep += PR_GetDirectorySeparator();  nsAutoString sbdSep;  rv = nsGetMailFolderSeparator(sbdSep);  if (NS_FAILED(rv)) return rv;  nsAutoString uri = uriStr;  if (uri.Find(rootURI) != 0)     // if doesn't start with rootURI    return NS_ERROR_FAILURE;  // verify that rootURI starts with "mailbox:/" or "mailbox_message:/"  if ((strcmp(rootURI, kMailboxRootURI) != 0) &&       (strcmp(rootURI, kMailboxMessageRootURI) != 0)) {    pathResult = nsnull;    return NS_ERROR_FAILURE;  }  // the server name is the first component of the path, so extract it out  PRInt32 hostStart;  hostStart = uri.Find('/');  if (hostStart <= 0) return NS_ERROR_FAILURE;  // skip past all //  while (uri[hostStart]=='/') hostStart++;  // cut mailbox://hostname/folder -> hostname/folder  nsAutoString hostname;  uri.Right(hostname, uri.Length() - hostStart);  PRInt32 hostEnd = hostname.Find('/');  // folder comes after the hostname, after the '/'  nsAutoString folder;  hostname.Right(folder, hostname.Length() - hostEnd - 1);  // cut off first '/' and everything following it  // hostname/folder -> hostname  if (hostEnd >0) {    hostname.Truncate(hostEnd);  }    // local mail case  // should return a list of all local mail folders? or maybe nothing  // at all?  char *hostchar = hostname.ToNewCString();  rv = nsGetMailboxRoot(hostchar, pathResult);  printf("nsGetMailboxRoot(%s) = %s\n\tfolder = %s\n",         hostchar, (const char*)pathResult,         folder.ToNewCString());  delete[] hostchar;  if (NS_FAILED(rv)) {    pathResult = nsnull;    return rv;  }#if 0  nsAutoString path="";  uri.Cut(0, nsCRT::strlen(rootURI));  PRInt32 uriLen = uri.Length();  PRInt32 pos;  while(uriLen > 0) {    nsAutoString folderName;    PRInt32 leadingPos;    // if it's the first character then remove it.    while ((leadingPos = uri.Find('/')) == 0) {      uri.Cut(0, 1);      uriLen--;    }    if (uriLen == 0)      break;    pos = uri.Find('/');    if (pos < 0)      pos = uriLen;    PRInt32 leftRes = uri.Left(folderName, pos);    NS_ASSERTION(leftRes == pos,                 "something wrong with nsString");	//We only want to add this after the first time around.	if(path.Length() > 0)	{		path += sep;		path += PR_GetDirectorySeparator();	}    // the first time around the separator is special because    // the root mail folder doesn't end with .sbd    sep = sbdSep;    path += folderName;    uri.Cut(0, pos);    uriLen -= pos;  }  if(path.Length() > 0)	  pathResult +=path;#endif  pathResult += folder;  return NS_OK;}