/** Returns the name of the Eclipse application launcher. */
  private static String getLauncherName(String name, String os, File installFolder) {
    if (os == null) {
      EnvironmentInfo info =
          (EnvironmentInfo)
              ServiceHelper.getService(Activator.getContext(), EnvironmentInfo.class.getName());
      if (info == null) return null;
      os = info.getOS();
    }

    if (os.equals(org.eclipse.osgi.service.environment.Constants.OS_WIN32)) {
      IPath path = new Path(name);
      if ("exe".equals(path.getFileExtension())) // $NON-NLS-1$
      return name;
      return name + ".exe"; // $NON-NLS-1$
    }
    if (os.equals(Constants.MACOSX_BUNDLED)) {
      return "/Contents/MacOS/" + name; // $NON-NLS-1$
    }

    if (os.equals(org.eclipse.osgi.service.environment.Constants.OS_MACOSX)) {
      IPath path = new Path(name);
      if (path.segment(0).endsWith(".app")) // $NON-NLS-1$
      return name;

      String appName = null;
      if (installFolder != null) {
        File appFolder = new File(installFolder, name + ".app"); // $NON-NLS-1$
        if (appFolder.exists()) {
          try {
            appName = appFolder.getCanonicalFile().getName();
          } catch (IOException e) {
            appName = appFolder.getName();
          }
        }
      }

      StringBuffer buffer = new StringBuffer();
      if (appName != null) {
        buffer.append(appName);
      } else {
        buffer.append(name.substring(0, 1).toUpperCase());
        buffer.append(name.substring(1));
        buffer.append(".app"); // $NON-NLS-1$
      }
      buffer.append("/Contents/MacOS/"); // $NON-NLS-1$
      buffer.append(name);
      return buffer.toString();
    }
    return name;
  }
 // Fully read the file pointed to by the given path
 private String read(String path) {
   File file = new File(path);
   if (!file.exists()) return null;
   StringBuffer buffer = new StringBuffer();
   BufferedReader reader = null;
   try {
     reader = new BufferedReader(new FileReader(file));
     for (String line = reader.readLine(); line != null; line = reader.readLine()) {
       buffer.append(line);
       buffer.append('\n');
     }
   } catch (IOException e) {
     // TODO
   } finally {
     if (reader != null)
       try {
         reader.close();
       } catch (IOException e) {
         // ignore
       }
   }
   return buffer.toString();
 }
  /*
   * Return a file handle pointing to the platform binary zip. Method never returns null because
   * it will fail an assert before that.
   */
  private File getPlatformZip() {
    String property = null;
    File file = null;
    if (propertyToPlatformArchive != null) {
      property = getValueFor(propertyToPlatformArchive);
      String message =
          "Need to set the "
              + "\""
              + propertyToPlatformArchive
              + "\" system property with a valid path to the platform binary drop or copy the archive to be a sibling of the install folder.";
      if (property == null) {
        fail(message);
      }
      file = new File(property);
      assertNotNull(message, file);
      assertTrue(message, file.exists());
      assertTrue("File is zero length: " + file.getAbsolutePath(), file.length() > 0);
      return file;
    }

    property = getValueFor("org.eclipse.equinox.p2.reconciler.tests.platform.archive");
    if (property == null) {
      // the releng test framework copies the zip so let's look for it...
      // it will be a sibling of the eclipse/ folder that we are running
      File installLocation = getInstallLocation();
      if (Platform.getWS().equals(Platform.WS_COCOA))
        installLocation = installLocation.getParentFile().getParentFile();

      if (installLocation != null) {
        // parent will be "eclipse" and the parent's parent will be "eclipse-testing"
        File parent = installLocation.getParentFile();
        if (parent != null) {
          parent = parent.getParentFile();
          if (parent != null) {
            File[] children =
                parent.listFiles(
                    new FileFilter() {
                      public boolean accept(File pathname) {
                        String name = pathname.getName();
                        return name.startsWith("eclipse-platform-");
                      }
                    });
            if (children != null && children.length == 1) file = children[0];
          }
        }
      }
    } else {
      file = new File(property);
    }
    StringBuffer detailedMessage = new StringBuffer(600);
    detailedMessage
        .append(" propertyToPlatformArchive was ")
        .append(propertyToPlatformArchive == null ? " not set " : propertyToPlatformArchive)
        .append('\n');
    detailedMessage
        .append(" org.eclipse.equinox.p2.reconciler.tests.platform.archive was ")
        .append(property == null ? " not set " : property)
        .append('\n');
    detailedMessage.append(" install location is ").append(getInstallLocation()).append('\n');
    String message =
        "Need to set the \"org.eclipse.equinox.p2.reconciler.tests.platform.archive\" system property with a valid path to the platform binary drop or copy the archive to be a sibling of the install folder.";
    assertNotNull(message + "\n" + detailedMessage, file);
    assertTrue(message, file.exists());
    assertTrue("File is zero length: " + file.getAbsolutePath(), file.length() > 0);
    return file;
  }