Backout 75e0a5a581bb (bug 775588) due to bustage.

This commit is contained in:
Ryan VanderMeulen 2012-07-26 21:34:36 -04:00
parent da5c10dc30
commit 972c2fbfec

View File

@ -53,34 +53,10 @@ namespace {
*/
bool gInitialized = false;
typedef struct {
/**
* The name of the directory holding all the libraries (libxpcom, libnss, etc.)
*/
nsString libdir;
nsString tmpdir;
nsString profiledir;
} Paths;
/**
* System directories.
* The name of the directory holding all the libraries (libxpcom, libnss, etc.)
*/
Paths* gPaths;
}
/**
* Return the path to one of the special directories.
*/
nsresult GetPathToSpecialDir(const char *aKey, nsString aOutPath)
{
nsCOMPtr<nsIFile> file;
nsresult rv = NS_GetSpecialDirectory(aKey, getter_AddRefs(file));
if (NS_FAILED(rv) || !file) {
return rv;
}
return file->GetPath(aOutPath);
nsString* gLibDirectory;
}
/**
@ -96,45 +72,23 @@ nsresult InitOSFileConstants()
gInitialized = true;
ScopedDeletePtr<Paths> paths(new Paths);
// Initialize paths->libdir
nsresult rv = NS_GetSpecialDirectory(aKey, getter_AddRefs(file));
nsCOMPtr<nsIFile> file;
nsresult rv = NS_GetSpecialDirectory("XpcomLib", getter_AddRefs(file));
if (NS_FAILED(rv) || !file) {
// Initialize gLibDirectory
nsCOMPtr<nsIFile> xpcomLib;
nsresult rv = NS_GetSpecialDirectory("XpcomLib", getter_AddRefs(xpcomLib));
if (NS_FAILED(rv) || !xpcomLib) {
return rv;
}
nsCOMPtr<nsIFile> libDir;
rv = file->GetParent(getter_AddRefs(libDir));
rv = xpcomLib->GetParent(getter_AddRefs(libDir));
if (NS_FAILED(rv)) {
return rv;
}
rv = libDir->GetPath(paths.rwget()->libdir);
if (NS_FAILED(rv)) {
return rv;
}
rv = GetPathToSpecialDir("TmpD", paths.rwget()->tmpdir);
if (NS_FAILED(rv)) {
return rv;
}
rv = GetPathToSpecialDir("ProfD", paths.rwget()->profiledir);
if (NS_FAILED(rv)) {
return rv;
}
gPaths = paths.forget();
return NS_OK;
gLibDirectory = new nsString();
return libDir->GetPath(*gLibDirectory);
}
/**
* Perform the cleaning up that can only be executed on the main thread.
*/
void CleanupOSFileConstants()
{
MOZ_ASSERT(NS_IsMainThread());
@ -143,7 +97,7 @@ void CleanupOSFileConstants()
}
gInitialized = false;
delete gPaths;
delete gLibDirectory;
}
@ -523,17 +477,6 @@ JSObject *GetOrCreateObjectProperty(JSContext *cx, JSObject *aObject,
return JS_DefineObject(cx, aObject, aProperty, NULL, NULL, JSPROP_ENUMERATE);
}
/**
* Set a property of an object from a nsString.
*/
bool SetStringProperty(JSContext *cx, JSObject *aObject, const char *aProperty,
const nsString aValue)
{
JSString* strValue = JS_NewUCStringCopyZ(cx, aValue.get());
jsval valValue = STRING_TO_JSVAL(strValue);
return JS_SetProperty(cx, aObject, aProperty, &valValue);
}
/**
* Define OS-specific constants.
*
@ -609,7 +552,7 @@ bool DefineOSFileConstants(JSContext *cx, JSObject *global)
// Locate libxul
{
nsAutoString xulPath(gPaths->libdir);
nsAutoString xulPath(*gLibDirectory);
xulPath.Append(PR_GetDirectorySeparator());
@ -624,19 +567,13 @@ bool DefineOSFileConstants(JSContext *cx, JSObject *global)
xulPath.Append(NS_LITERAL_STRING(DLL_SUFFIX));
#endif // defined(XP_MACOSX)
if (!SetStringProperty(cx, objPath, "libxul", xulPath)) {
JSString* strPathToLibXUL = JS_NewUCStringCopyZ(cx, xulPath.get());
jsval valXul = STRING_TO_JSVAL(strPathToLibXUL);
if (!JS_SetProperty(cx, objPath, "libxul", &valXul)) {
return false;
}
}
if (!SetStringProperty(cx, objPath, "tmpdir", gPaths->tmpdir)) {
return false;
}
if (!SetStringProperty(cx, objPath, "profiledir", gPaths->libdir)) {
return false;
}
return true;
}