static bool GetPluginPaths(const nsAString& aPluginPath, nsCString &aPluginDirectoryPath, nsCString &aPluginFilePath) { nsCOMPtr<nsIFile> libDirectory, libFile; if (!GetPluginFile(aPluginPath, libDirectory, libFile)) { return false; } // Mac sandbox rules expect paths to actual files and directories -- not // soft links. aPluginDirectoryPath = GetNativeTarget(libDirectory); aPluginFilePath = GetNativeTarget(libFile); return true; }
static bool GetAppPaths(nsCString &aAppPath, nsCString &aAppBinaryPath) { nsAutoCString appPath; nsAutoCString appBinaryPath( (CommandLine::ForCurrentProcess()->argv()[0]).c_str()); nsAutoCString::const_iterator start, end; appBinaryPath.BeginReading(start); appBinaryPath.EndReading(end); if (RFindInReadable(NS_LITERAL_CSTRING(".app/Contents/MacOS/"), start, end)) { end = start; ++end; ++end; ++end; ++end; appBinaryPath.BeginReading(start); appPath.Assign(Substring(start, end)); } else { return false; } nsCOMPtr<nsIFile> app, appBinary; nsresult rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(appPath), true, getter_AddRefs(app)); if (NS_FAILED(rv)) { return false; } rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(appBinaryPath), true, getter_AddRefs(appBinary)); if (NS_FAILED(rv)) { return false; } // Mac sandbox rules expect paths to actual files and directories -- not // soft links. aAppPath = GetNativeTarget(app); appBinaryPath = GetNativeTarget(appBinary); return true; }