char *newStr=nsnull; char *temp = PL_strdup(curPos); char *token = nsCRT::strtok(temp, "/", &newStr); while (token) { nsCAutoString dir(token);   token = nsCRT::strtok(newStr, "/", &newStr);   if (token) { NS_MsgHashIfNecessary(dir); dir += sbdSep; pathResult += (const char *) dir; } else { NS_MsgHashIfNecessary(dir); pathResult += (const char *) dir; } } PL_strfree(temp);
nsCAutoString newPath(""); NS_MsgCreatePathStringFromFolderURI(curPos, newPath);  pathResult+=newPath.GetBuffer();
nsLocalURI2Path(const char* rootURI, const char* uriStr,                nsFileSpec& pathResult){  nsresult rv;    // verify that rootURI starts with "mailbox:/" or "mailbox_message:/"  if ((PL_strcmp(rootURI, kMailboxRootURI) != 0) &&       (PL_strcmp(rootURI, kMailboxMessageRootURI) != 0)) {    pathResult = nsnull;    return NS_ERROR_FAILURE;  }  // verify that uristr starts with rooturi  nsAutoString uri = uriStr;  if (uri.Find(rootURI) != 0)    return NS_ERROR_FAILURE;  nsCOMPtr<nsIMsgIncomingServer> server;  rv = nsLocalURI2Server(uriStr, getter_AddRefs(server));    if (NS_FAILED(rv))  	return rv;    // now ask the server what it's root is  // and begin pathResult with the mailbox root  nsCOMPtr<nsIFileSpec> localPath;  rv = server->GetLocalPath(getter_AddRefs(localPath));  if (NS_SUCCEEDED(rv))     localPath->GetFileSpec(&pathResult);  const char *curPos = uriStr + PL_strlen(rootURI);  if (curPos) {        // advance past hostname    while ((*curPos)=='/') curPos++;    while (*curPos && (*curPos)!='/') curPos++;    while ((*curPos)=='/') curPos++;    // get the seperator    nsAutoString sbdSep;    rv = nsGetMailFolderSeparator(sbdSep);        // for each token in between the /'s, put a .sbd on the end and    // append to the path    char *newStr=nsnull;    char *temp = PL_strdup(curPos);    char *token = nsCRT::strtok(temp, "/", &newStr);    while (token) {      nsCAutoString dir(token);            // look for next token      token = nsCRT::strtok(newStr, "/", &newStr);            // check if we're the last entry      if (token) {        NS_MsgHashIfNecessary(dir);        dir += sbdSep;            // no, we're not, so append .sbd        pathResult += (const char *) dir;      }      else {        NS_MsgHashIfNecessary(dir);        pathResult += (const char *) dir;      }    }    PL_strfree(temp);  }  return NS_OK;}