private static String getEclipseHomeLocation(String launcher) { if (launcher == null) return null; File launcherFile = new File(launcher); if (launcherFile.getParent() == null) return null; File launcherDir = new File(launcherFile.getParent()); // check for mac os; the os check is copied from EclipseEnvironmentInfo. String macosx = org.eclipse.osgi.service.environment.Constants.OS_MACOSX; if (macosx.equals(EclipseEnvironmentInfo.getDefault().getOS())) launcherDir = getMacOSEclipsoeHomeLocation(launcherDir); return (launcherDir.exists() && launcherDir.isDirectory()) ? launcherDir.getAbsolutePath() : null; }
private static File getMacOSEclipsoeHomeLocation(File launcherDir) { // TODO for now we go up three directories from the launcher dir as long as the parent dir is // named MacOS; is this always the case? // TODO not sure if case is important if (!launcherDir.getName().equalsIgnoreCase("macos")) // $NON-NLS-1$ return launcherDir; // don't do the up three stuff if not in macos directory String launcherParent = launcherDir.getParent(); if (launcherParent != null) launcherParent = new File(launcherParent).getParent(); if (launcherParent != null) launcherParent = new File(launcherParent).getParent(); return launcherParent == null ? null : new File(launcherParent); }