Ejemplo n.º 1
0
  private void createOutputJar() {
    // Me make the .uninstaller directory
    String dest =
        IoHelper.translatePath(installdata.getInfo().getUninstallerPath(), variableSubstitutor);
    String jar = dest + File.separator + installdata.getInfo().getUninstallerName();
    File pathMaker = new File(dest);
    pathMaker.mkdirs();

    // We log the uninstaller deletion information
    udata.setUninstallerJarFilename(jar);
    udata.setUninstallerPath(dest);

    // We open our final jar file
    try {
      out = new FileOutputStream(jar);
    } catch (FileNotFoundException e) {
      throw new IzPackException("Problem writing uninstaller jar", e);
    }

    try {
      // Intersect a buffer else byte for byte will be written to the file.
      bos = new BufferedOutputStream(out);
      outJar = new JarOutputStream(bos);
    } catch (IOException e) {
      throw new IzPackException("Problem writing uninstaller jar", e);
    }

    outJar.setLevel(9);
    udata.addFile(jar, true);
  }
  /**
   * Puts the uninstaller.
   *
   * @exception Exception Description of the Exception
   */
  private void putUninstaller() throws Exception {
    // Me make the .uninstaller directory
    String dest = translatePath("$INSTALL_PATH") + File.separator + "Uninstaller";
    String jar = dest + File.separator + "uninstaller.jar";
    File pathMaker = new File(dest);
    pathMaker.mkdirs();

    // We log the uninstaller deletion information
    UninstallData udata = UninstallData.getInstance();
    udata.setUninstallerJarFilename(jar);
    udata.setUninstallerPath(dest);

    // We open our final jar file
    FileOutputStream out = new FileOutputStream(jar);
    ZipOutputStream outJar = new ZipOutputStream(out);
    idata.uninstallOutJar = outJar;
    outJar.setLevel(9);
    udata.addFile(jar);

    // We copy the uninstaller
    InputStream in = getClass().getResourceAsStream("/res/IzPack.uninstaller");
    ZipInputStream inRes = new ZipInputStream(in);
    ZipEntry zentry = inRes.getNextEntry();
    while (zentry != null) {
      // Puts a new entry
      outJar.putNextEntry(new ZipEntry(zentry.getName()));

      // Byte to byte copy
      int unc = inRes.read();
      while (unc != -1) {
        outJar.write(unc);
        unc = inRes.read();
      }

      // Next one please
      inRes.closeEntry();
      outJar.closeEntry();
      zentry = inRes.getNextEntry();
    }
    inRes.close();

    // We put the langpack
    in = getClass().getResourceAsStream("/langpacks/" + idata.localeISO3 + ".xml");
    outJar.putNextEntry(new ZipEntry("langpack.xml"));
    int read = in.read();
    while (read != -1) {
      outJar.write(read);
      read = in.read();
    }
    outJar.closeEntry();
  }