uri = PR_smprintf("%s/%s", (const char*)serverURI, relpath);
nsCAutoString pathStr(relpath); PRInt32 sbdIndex; while((sbdIndex = pathStr.Find(".sbd", PR_TRUE)) != -1) { pathStr.Cut(sbdIndex, 4); }  uri = PR_smprintf("%s/%s", (const char*)serverURI, pathStr.GetBuffer());
static char *nsMailboxGetURI(const char *nativepath){    nsresult rv;    char *uri = nsnull;    NS_WITH_SERVICE(nsIMsgAccountManager, accountManager,                    NS_MSGACCOUNTMANAGER_PROGID, &rv);    if (NS_FAILED(rv)) return nsnull;    nsCOMPtr<nsISupportsArray> serverArray;    accountManager->GetAllServers(getter_AddRefs(serverArray));    // do a char*->fileSpec->char* conversion to normalize the path    nsFilePath filePath(nativepath);        PRUint32 cnt;    rv = serverArray->Count(&cnt);    if (NS_FAILED(rv)) return nsnull;    PRInt32 count = cnt;    PRInt32 i;    for (i=0; i<count; i++) {        nsISupports* serverSupports = serverArray->ElementAt(i);        nsCOMPtr<nsIMsgIncomingServer> server =            do_QueryInterface(serverSupports);        NS_RELEASE(serverSupports);        if (!server) continue;        // get the path string, convert it to an nsFilePath        nsCOMPtr<nsIFileSpec> nativeServerPath;        rv = server->GetLocalPath(getter_AddRefs(nativeServerPath));        if (NS_FAILED(rv)) continue;                nsFileSpec spec;        nativeServerPath->GetFileSpec(&spec);        nsFilePath serverPath(spec);                // check if filepath begins with serverPath        PRInt32 len = PL_strlen(serverPath);        if (PL_strncasecmp(serverPath, filePath, len) == 0) {            nsXPIDLCString serverURI;            rv = server->GetServerURI(getter_Copies(serverURI));            if (NS_FAILED(rv)) continue;                        // the relpath is just past the serverpath            const char *relpath = nativepath + len;            // skip past leading / if any            while (*relpath == '/') relpath++;            uri = PR_smprintf("%s/%s", (const char*)serverURI, relpath);            break;        }    }    return uri;}