зеркало из https://github.com/mozilla/gecko-dev.git
Checkin for bug 120866. Add getenv() support to autoconfig module. Checking in for Jerry Tan. r=dveditz, sr=alecf, a=asa.
This commit is contained in:
Родитель
9b4a13f681
Коммит
97ac9e9fa4
|
@ -197,3 +197,15 @@ function displayError(message) {
|
|||
promptService.alert(null, title, err);
|
||||
}
|
||||
}
|
||||
|
||||
function getenv(name) {
|
||||
|
||||
try {
|
||||
var currentProcess=Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
|
||||
return currentProcess.getEnvironment(name);
|
||||
}
|
||||
catch(e) {
|
||||
displayError("getEnvironment failed with error: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,16 @@ interface nsIProcess : nsISupports
|
|||
readonly attribute string processName;
|
||||
readonly attribute unsigned long processSignature;
|
||||
readonly attribute long exitValue;
|
||||
|
||||
/**
|
||||
* Called to get the value of environment variable
|
||||
*
|
||||
* @param aName The string enviroment variable name
|
||||
* @exception NS_ERROR_OUT_OF_MEMORY
|
||||
*
|
||||
* @return The value of the requested string environment variable name
|
||||
*/
|
||||
string getEnvironment(in string aName);
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
#include "nsProcess.h"
|
||||
#include "prtypes.h"
|
||||
#include "prio.h"
|
||||
#include "prenv.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -345,3 +347,13 @@ nsProcess::GetExitValue(PRInt32 *aExitValue)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProcess::GetEnvironment(const char *aName, char **aValue)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aName);
|
||||
*aValue = nsCRT::strdup(PR_GetEnv(aName));
|
||||
if (!*aValue)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
|
||||
#include "prtypes.h"
|
||||
#include "prio.h"
|
||||
#include "prenv.h"
|
||||
#include "nsCRT.h"
|
||||
#include "prthread.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -138,6 +140,17 @@ NS_IMETHODIMP nsProcess::InitWithPid(PRUint32 pid)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProcess::GetEnvironment(const char *aName, char **aValue)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aName);
|
||||
*aValue = nsCRT::strdup(PR_GetEnv(aName));
|
||||
if (!*aValue)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProcess::GetLocation(nsIFile** aLocation)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче