printf("Warning: MOZILLA_FIVE_HOME not set.\n");
NS_WARNING("Warning: MOZILLA_FIVE_HOME not set.\n");
static nsresult GetCurrentProcessDirectory(nsILocalFile** aFile){    nsCOMPtr<nsILocalFile> localFile;    NS_NewLocalFile(nsnull, PR_FALSE, getter_AddRefs(localFile));    if (!localFile)        return NS_ERROR_OUT_OF_MEMORY;   #ifdef XP_PC#ifdef XP_OS2    PPIB ppib;    PTIB ptib;    char buffer[CCHMAXPATH];    DosGetInfoBlocks( &ptib, &ppib);    DosQueryModuleName( ppib->pib_hmte, CCHMAXPATH, buffer);    *strrchr( buffer, '\\') = '\0'; // XXX DBCS misery    localFile->InitWithPath(buffer);    NS_IF_ADDREF(*aFile = localFile);    return NS_OK;#else    char buf[MAX_PATH];    if ( GetModuleFileName(0, buf, sizeof(buf)) )     {        // chop of the executable name by finding the rightmost backslash        char* lastSlash = PL_strrchr(buf, '\\');        if (lastSlash)            *(lastSlash + 1) = '\0';                localFile->InitWithPath(buf);        NS_IF_ADDREF(*aFile = localFile);        return NS_OK;    }#endif#elif defined(XP_MAC)    // get info for the the current process to determine the directory    // its located in    OSErr err;    ProcessSerialNumber psn;    if (!(err = GetCurrentProcess(&psn)))    {        ProcessInfoRec pInfo;        FSSpec         tempSpec;        // initialize ProcessInfoRec before calling        // GetProcessInformation() or die horribly.        pInfo.processName = nil;        pInfo.processAppSpec = &tempSpec;        pInfo.processInfoLength = sizeof(ProcessInfoRec);        if (!(err = GetProcessInformation(&psn, &pInfo)))        {            FSSpec appFSSpec = *(pInfo.processAppSpec);                        // Truncate the nsame so the spec is just to the app directory            appFSSpec.name[0] = 0;        	nsCOMPtr<nsILocalFileMac> localFileMac = do_QueryInterface((nsIFile*)localFile);		    if (localFileMac)             {                localFileMac->InitWithFSSpec(&appFSSpec);                NS_IF_ADDREF(*aFile = localFile);                return NS_OK;            }        }    }#elif defined(XP_UNIX)    // In the absence of a good way to get the executable directory let    // us try this for unix:    //	- if MOZILLA_FIVE_HOME is defined, that is it    //	- else give the current directory    char buf[MAXPATHLEN];    char *moz5 = PR_GetEnv("MOZILLA_FIVE_HOME");    if (moz5)    {        localFile->InitWithPath(moz5);        localFile->Normalize();        NS_IF_ADDREF(*aFile = localFile);        return NS_OK;    }    else    {        static PRBool firstWarning = PR_TRUE;        if(firstWarning) {            // Warn that MOZILLA_FIVE_HOME not set, once.            printf("Warning: MOZILLA_FIVE_HOME not set.\n");            firstWarning = PR_FALSE;        }        // Fall back to current directory.        if (getcwd(buf, sizeof(buf)))        {            localFile->InitWithPath(buf);            NS_IF_ADDREF(*aFile = localFile);            return NS_OK;        }    }#elif defined(XP_BEOS)    char *moz5 = getenv("MOZILLA_FIVE_HOME");    if (moz5)    {        localFile->InitWithPath(moz5);        NS_IF_ADDREF(*aFile = localFile);        return NS_OK;    }    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;          localFile->InitWithPath(buf);          NS_IF_ADDREF(*aFile = localFile);          return NS_OK;        }      }    }#endif        NS_ERROR("unable to get current process directory");    return NS_ERROR_FAILURE;}