nsAutoString pathStr = spec; nsAutoString rootStr = root;
const char *path = spec; nsAutoString pathStr(path); path = root; nsAutoString rootStr(path);
nsPath2URI(const char* rootURI, nsFileSpec& spec, char* *uri){  nsresult rv;  nsAutoString sep;  rv = nsGetMailFolderSeparator(sep);  if (NS_FAILED(rv)) return rv;  PRUint32 sepLen = sep.Length();  nsFileSpec root;  rv = nsGetMailboxRoot(root);  if (NS_FAILED(rv)) return rv;  nsAutoString pathStr = spec;  nsAutoString rootStr = root;  PRInt32 pos = pathStr.Find(rootStr);  if (pos != 0)     // if doesn't start with root path    return NS_ERROR_FAILURE;  nsAutoString uriStr(rootURI);  PRUint32 rootStrLen = rootStr.Length();  pathStr.Cut(0, rootStrLen);  PRInt32 pathStrLen = pathStr.Length();  char dirSep = PR_GetDirectorySeparator();    while (pathStrLen > 0) {    nsAutoString folderName;        PRInt32 leadingPos;    // if it's the first character then remove it.    while ((leadingPos = pathStr.Find(dirSep)) == 0) {      pathStr.Cut(0, 1);      pathStrLen--;    }    if (pathStrLen == 0)      break;    pos = pathStr.Find(sep);    if (pos < 0)       pos = pathStrLen;    PRInt32 cnt = pathStr.Left(folderName, pos);    NS_ASSERTION(cnt == pos, "something wrong with nsString");    pathStr.Cut(0, pos + sepLen);    pathStrLen -= pos + sepLen;    uriStr += '/';    uriStr += folderName;  }  *uri = uriStr.ToNewCString();  return NS_OK;}