Exemplo n.º 1
0
static bool
LoadStaticData(int argc, const char *argv[])
{
  char xpcomPath[MAXPATHLEN];
  bool ok = GetXPCOMPath(argv[0], xpcomPath, MAXPATHLEN);
  NS_ENSURE_TRUE(ok, false);

  ok = LoadLibxul(xpcomPath);
  NS_ENSURE_TRUE(ok, false);

  char progDir[MAXPATHLEN];
  ok = GetDirnameSlash(xpcomPath, progDir, MAXPATHLEN);
  NS_ENSURE_TRUE(ok, false);

  nsCOMPtr<nsIFile> appini = GetAppIni(argc, argv);
  const nsXREAppData *appData;
  if (appini) {
    nsresult rv =
      XRE_CreateAppData(appini, const_cast<nsXREAppData**>(&appData));
    NS_ENSURE_SUCCESS(rv, false);
  } else {
    appData = &sAppData;
  }

  XRE_ProcLoaderPreload(progDir, appData);

  if (appini) {
    XRE_FreeAppData(const_cast<nsXREAppData*>(appData));
  }

  return true;
}
Exemplo n.º 2
0
static bool
GetXPCOMPath(const char *aProgram, char *aOutPath, int aMaxLen)
{
  auto progBuf = mozilla::MakeUnique<char[]>(aMaxLen);
  nsresult rv = mozilla::BinaryPath::Get(aProgram, progBuf.get());
  NS_ENSURE_SUCCESS(rv, false);

  int len = GetDirnameSlash(progBuf.get(), aOutPath, aMaxLen);
  NS_ENSURE_TRUE(!!len, false);

  NS_ENSURE_TRUE((len + sizeof(XPCOM_DLL)) < (unsigned)aMaxLen, false);
  char *afterSlash = aOutPath + len;
  strcpy(afterSlash, XPCOM_DLL);
  return true;
}
Exemplo n.º 3
0
static bool
GetXPCOMPath(const char *aProgram, char *aOutPath, int aMaxLen)
{
  nsAutoArrayPtr<char> progBuf(new char[aMaxLen]);
  nsresult rv = mozilla::BinaryPath::Get(aProgram, progBuf);
  NS_ENSURE_SUCCESS(rv, false);

  int len = GetDirnameSlash(progBuf, aOutPath, aMaxLen);
  NS_ENSURE_TRUE(!!len, false);

  NS_ENSURE_TRUE((len + sizeof(XPCOM_DLL)) < aMaxLen, false);
  char *afterSlash = aOutPath + len;
  strcpy(afterSlash, XPCOM_DLL);
  return true;
}