Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
nsSpecialSystemDirectory.cpp File Reference
#include "nsSpecialSystemDirectory.h"
#include "nsDebug.h"
#include "plstr.h"
#include "nsHashtable.h"
#include "prlog.h"

Go to the source code of this file.

Classes

class  SystemDirectoriesKey

Defines

#define NS_SYSTEMDIR_HASH_NUM   (10)

Functions

 PR_STATIC_CALLBACK (PRBool) DeleteSystemDirKeys(nsHashKey *aKey
void void *closure delete ((nsFileSpec *) aData)
static void GetCurrentWorkingDirectory (nsFileSpec &aFileSpec)
static void GetCurrentProcessDirectory (nsFileSpec &aFileSpec)

Variables

voidaData
return PR_TRUE
static nsHashtable * systemDirectoriesLocations = NULL

Define Documentation

Definition at line 125 of file nsSpecialSystemDirectory.cpp.


Function Documentation

void void* closure delete ( (nsFileSpec *)  aData)

Here is the caller graph for this function:

static void GetCurrentProcessDirectory ( nsFileSpec aFileSpec) [static]

Definition at line 238 of file nsSpecialSystemDirectory.cpp.

{
#if defined (XP_WIN)
    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';

        aFileSpec = buf;
        return;
    }

#elif defined(XP_OS2)
    PPIB ppib;
    PTIB ptib;
    char buffer[CCHMAXPATH];
    DosGetInfoBlocks( &ptib, &ppib);
    DosQueryModuleName( ppib->pib_hmte, CCHMAXPATH, buffer);
    *strrchr( buffer, '\\') = '\0'; // XXX DBCS misery
    aFileSpec = buffer;
    return;

#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)
    {
        aFileSpec = moz5;
        return;
    }
    else
    {
#if defined(DEBUG)
        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;
        }
#endif /* DEBUG */

        // Fall back to current directory.
        if (getcwd(buf, sizeof(buf)))
        {
            aFileSpec = buf;
            return;
        }
    }

#elif defined(XP_BEOS)

    char *moz5 = getenv("MOZILLA_FIVE_HOME");
    if (moz5)
    {
        aFileSpec = moz5;
        return;
    }
    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;
          aFileSpec = buf;
          return;
        }
      }
    }

#endif

    NS_ERROR("unable to get current process directory");
} // GetCurrentProcessDirectory()

Here is the call graph for this function:

static void GetCurrentWorkingDirectory ( nsFileSpec aFileSpec) [static]

Definition at line 230 of file nsSpecialSystemDirectory.cpp.

{
    aFileSpec = ".";
    return;
} // GetCurrentWorkingDirectory

Variable Documentation

Definition at line 119 of file nsSpecialSystemDirectory.cpp.

Definition at line 122 of file nsSpecialSystemDirectory.cpp.

nsHashtable* systemDirectoriesLocations = NULL [static]

Definition at line 126 of file nsSpecialSystemDirectory.cpp.