diff options
Diffstat (limited to 'dom/system/OSFileConstants.cpp')
-rw-r--r-- | dom/system/OSFileConstants.cpp | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/dom/system/OSFileConstants.cpp b/dom/system/OSFileConstants.cpp index 2b8a7e5369..551ed5773f 100644 --- a/dom/system/OSFileConstants.cpp +++ b/dom/system/OSFileConstants.cpp @@ -24,6 +24,10 @@ #include <linux/fadvise.h> #endif // defined(XP_LINUX) +#if defined(XP_MACOSX) +#include "copyfile.h" +#endif // defined(XP_MACOSX) + #if defined(XP_WIN) #include <windows.h> #include <accctrl.h> @@ -122,6 +126,22 @@ struct Paths { nsString winStartMenuProgsDir; #endif // defined(XP_WIN) +#if defined(XP_MACOSX) + /** + * The user's Library directory. + */ + nsString macUserLibDir; + /** + * The Application directory, that stores applications installed in the + * system. + */ + nsString macLocalApplicationsDir; + /** + * The user's trash directory. + */ + nsString macTrashDir; +#endif // defined(XP_MACOSX) + Paths() { libDir.SetIsVoid(true); @@ -136,6 +156,12 @@ struct Paths { winAppDataDir.SetIsVoid(true); winStartMenuProgsDir.SetIsVoid(true); #endif // defined(XP_WIN) + +#if defined(XP_MACOSX) + macUserLibDir.SetIsVoid(true); + macLocalApplicationsDir.SetIsVoid(true); + macTrashDir.SetIsVoid(true); +#endif // defined(XP_MACOSX) } }; @@ -280,6 +306,12 @@ nsresult InitOSFileConstants() GetPathToSpecialDir(NS_WIN_PROGRAMS_DIR, paths->winStartMenuProgsDir); #endif // defined(XP_WIN) +#if defined(XP_MACOSX) + GetPathToSpecialDir(NS_MAC_USER_LIB_DIR, paths->macUserLibDir); + GetPathToSpecialDir(NS_OSX_LOCAL_APPLICATIONS_DIR, paths->macLocalApplicationsDir); + GetPathToSpecialDir(NS_MAC_TRASH_DIR, paths->macTrashDir); +#endif // defined(XP_MACOSX) + gPaths = paths.forget(); // Get the umask from the system-info service. @@ -933,12 +965,20 @@ bool DefineOSFileConstants(JSContext *cx, JS::Handle<JSObject*> global) // Note that we don't actually provide the full path, only the name of the // library, which is sufficient to link to the library using js-ctypes. - // On all supported platforms, libxul is a library "xul" with regular +#if defined(XP_MACOSX) + // Under MacOS X, for some reason, libxul is called simply "XUL", + // and we need to provide the full path. + nsAutoString libxul; + libxul.Append(gPaths->libDir); + libxul.AppendLiteral("/XUL"); +#else + // On other platforms, libxul is a library "xul" with regular // library prefix/suffix. nsAutoString libxul; libxul.AppendLiteral(DLL_PREFIX); libxul.AppendLiteral("xul"); libxul.AppendLiteral(DLL_SUFFIX); +#endif // defined(XP_MACOSX) if (!SetStringProperty(cx, objPath, "libxul", libxul)) { return false; @@ -986,6 +1026,20 @@ bool DefineOSFileConstants(JSContext *cx, JS::Handle<JSObject*> global) } #endif // defined(XP_WIN) +#if defined(XP_MACOSX) + if (!SetStringProperty(cx, objPath, "macUserLibDir", gPaths->macUserLibDir)) { + return false; + } + + if (!SetStringProperty(cx, objPath, "macLocalApplicationsDir", gPaths->macLocalApplicationsDir)) { + return false; + } + + if (!SetStringProperty(cx, objPath, "macTrashDir", gPaths->macTrashDir)) { + return false; + } +#endif // defined(XP_MACOSX) + // sqlite3 is always a shared lib nsAutoString libsqlite3; libsqlite3.AppendLiteral(DLL_PREFIX); |