resourceBase = XP_STRDUP("usr/local/netscape/bin");
resourceBase = nsCRT::strdup("usr/local/netscape/bin");
MangleResourceIntoFileURL(const char* aResourceFileName) {    // XXX For now, resources are not in jar files     // Find base path name to the resource file    char* resourceBase;#ifdef XP_PC    // XXX For now, all resources are relative to the .exe file    resourceBase = (char *)PR_Malloc(_MAX_PATH);    DWORD mfnLen = GetModuleFileName(g_hInst, resourceBase, _MAX_PATH);    // Truncate the executable name from the rest of the path...    char* cp = strrchr(resourceBase, '\\');    if (nsnull != cp) {        *cp = '\0';    }    // Change the first ':' into a '|'    cp = PL_strchr(resourceBase, ':');    if (nsnull != cp) {        *cp = '|';    }#endif /* XP_PC */#ifdef XP_UNIX    //    // Obtain the resource: url base from the environment variable    //    // MOZILLA_FIVE_HOME    //    // Which is the standard place where mozilla stores global (ie, not    // user specific) data    //#ifndef MAXPATHLEN#define MAXPATHLEN 1024 // A good guess, i suppose#endif#define MOZILLA_FIVE_HOME "MOZILLA_FIVE_HOME"    static char * nsUnixMozillaHomePath = nsnull;    if (nsnull == nsUnixMozillaHomePath)    {        nsUnixMozillaHomePath = PR_GetEnv(MOZILLA_FIVE_HOME);    }    if (nsnull == nsUnixMozillaHomePath)    {        static char homepath[MAXPATHLEN];        FILE* pp;        if (!(pp = popen("pwd", "r"))) {#ifdef DEBUG            printf("RESOURCE protocol error in nsURL::mangeResourceIntoFileURL 1\n");#endif            return(nsnull);        }        if (fgets(homepath, MAXPATHLEN, pp)) {            homepath[PL_strlen(homepath)-1] = 0;        }        else {#ifdef DEBUG            printf("RESOURCE protocol error in nsURL::mangeResourceIntoFileURL 2\n");#endif            pclose(pp);            return(nsnull);        }        pclose(pp);        nsUnixMozillaHomePath = homepath;    }    resourceBase = XP_STRDUP(nsUnixMozillaHomePath);#ifdef DEBUG    {        static PRBool firstTime = PR_TRUE;        if (firstTime) {            firstTime = PR_FALSE;            printf("Using '%s' as the resource: base\n", resourceBase);        }    }#endif#endif /* XP_UNIX */#ifdef XP_BEOS    char *moz5 = getenv("MOZILLA_FIVE_HOME");    if (moz5)      resourceBase = XP_STRDUP(moz5);    else    {      static char buf[MAXPATHLEN];      int32 cookie = 0;      image_info info;      char *p;      *buf = 0;      if(get_next_image_info(0, &cookie, &info) == B_OK)      {        strcpy(buf, info.name);        if((p = strrchr(buf, '/')) != 0)        {          *p = 0;          resourceBase = XP_STRDUP(buf);        }        else          return nsnull;      }      else        return nsnull;    }#endif#ifdef XP_MAC    resourceBase = XP_STRDUP("usr/local/netscape/bin");#endif /* XP_MAC */    // Join base path to resource name    if (aResourceFileName[0] == '/') {        aResourceFileName++;    }    PRInt32 baseLen = PL_strlen(resourceBase);    PRInt32 resLen = PL_strlen(aResourceFileName);    PRInt32 totalLen = 8 + baseLen + 1 + resLen + 1;    char* fileName = (char *)PR_Malloc(totalLen);    PR_snprintf(fileName, totalLen, "file:///%s/%s", resourceBase, aResourceFileName);#ifdef XP_PC    // Change any backslashes into foreward slashes...    while ((cp = PL_strchr(fileName, '\\')) != 0) {        *cp = '/';        cp++;    }#endif /* XP_PC */    PR_Free(resourceBase);    return fileName;}