aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHolger Zickner <[email protected]>2004-09-21 10:46:08 +0000
committerHolger Zickner <[email protected]>2004-09-21 10:46:08 +0000
commit06201eb3d8ff68932c47877b666f801c55cb7258 (patch)
tree75c53a25b568245b1e2f5429a943468920df4dc0 /src
parentccb2d4d12dbcc113507dc600d54540eb757ce80a (diff)
FTP installer
Diffstat (limited to 'src')
-rw-r--r--src/jake2/qcommon/FS.java6
-rw-r--r--src/jake2/qcommon/Q2DataDialog.java666
2 files changed, 401 insertions, 271 deletions
diff --git a/src/jake2/qcommon/FS.java b/src/jake2/qcommon/FS.java
index acbdade..66b8a80 100644
--- a/src/jake2/qcommon/FS.java
+++ b/src/jake2/qcommon/FS.java
@@ -2,7 +2,7 @@
* FS.java
* Copyright (C) 2003
*
- * $Id: FS.java,v 1.6 2004-09-20 20:26:40 cawe Exp $
+ * $Id: FS.java,v 1.7 2004-09-21 10:46:07 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -116,8 +116,8 @@ public final class FS extends Globals {
// -1 if not found and 0 means write to root
if (index > 0) {
File f = new File(path.substring(0, index));
- if (!f.mkdirs()) {
- //Com.Printf("can't create path \"" + path + '"' + "\n" );
+ if (!f.mkdirs() && !f.isDirectory()) {
+ Com.Printf("can't create path \"" + path + '"' + "\n" );
}
}
}
diff --git a/src/jake2/qcommon/Q2DataDialog.java b/src/jake2/qcommon/Q2DataDialog.java
index 9f3d3af..dca6d47 100644
--- a/src/jake2/qcommon/Q2DataDialog.java
+++ b/src/jake2/qcommon/Q2DataDialog.java
@@ -1,268 +1,398 @@
-/*
- * Q2DataDialog.java
- *
- * Created on 17. September 2004, 20:13
- */
-
-package jake2.qcommon;
-
-import java.awt.*;
-import java.awt.DisplayMode;
-import java.awt.GraphicsEnvironment;
-import java.io.IOException;
-
-import javax.swing.*;
-import javax.swing.JFileChooser;
-import javax.swing.JPanel;
-
-/**
- *
- * @author hoz
- */
-public class Q2DataDialog extends javax.swing.JDialog {
-
- /** Creates new form Q2DataDialog */
- public Q2DataDialog() {
- super();
- initComponents();
-
- DisplayMode mode = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode();
- int x = (mode.getWidth() - getWidth()) / 2;
- int y = (mode.getHeight() - getHeight()) / 2;
- setLocation(x, y);
- }
-
- /** This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
- private void initComponents() {//GEN-BEGIN:initComponents
- java.awt.GridBagConstraints gridBagConstraints;
-
- choosePanel = new javax.swing.JPanel();
- statusPanel = new JPanel();
- status = new JLabel("initializing Jake2...");
- jTextField1 = new javax.swing.JTextField();
- changeButton = new javax.swing.JButton();
- installButton = new javax.swing.JButton();
- exitButton = new javax.swing.JButton();
- okButton = new javax.swing.JButton();
-
- setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
- setTitle("Jake2 - Bytonic Software");
-
- setResizable(false);
- addWindowListener(new java.awt.event.WindowAdapter() {
- public void windowClosing(java.awt.event.WindowEvent evt) {
- formWindowClosing(evt);
- }
- });
-
- choosePanel.setLayout(new java.awt.GridBagLayout());
-
- choosePanel.setMaximumSize(new java.awt.Dimension(400, 100));
- choosePanel.setMinimumSize(new java.awt.Dimension(400, 100));
- choosePanel.setPreferredSize(new java.awt.Dimension(400, 100));
- jTextField1.setPreferredSize(null);
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 0;
- gridBagConstraints.gridwidth = 2;
- gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
- gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
- gridBagConstraints.weightx = 1.0;
- choosePanel.add(jTextField1, gridBagConstraints);
-
- changeButton.setText("change");
- changeButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- changeButtonActionPerformed(evt);
- }
- });
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 2;
- gridBagConstraints.gridy = 0;
- gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
- gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
- choosePanel.add(changeButton, gridBagConstraints);
-
- installButton.setText("Install");
- installButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- installButtonActionPerformed(evt);
- }
- });
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 1;
- gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
- gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
- choosePanel.add(installButton, gridBagConstraints);
-
- exitButton.setText("Exit");
- exitButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- exitButtonActionPerformed(evt);
- }
- });
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 1;
- gridBagConstraints.gridy = 1;
- gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
- choosePanel.add(exitButton, gridBagConstraints);
-
- okButton.setText("OK");
- okButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- okButtonActionPerformed(evt);
- }
- });
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 2;
- gridBagConstraints.gridy = 1;
- gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
- gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
- choosePanel.add(okButton, gridBagConstraints);
-
- //getContentPane().add(choosePanel, java.awt.BorderLayout.SOUTH);
-
- Jake2Canvas c = new Jake2Canvas();
- getContentPane().add(c, BorderLayout.CENTER);
-
- statusPanel.setLayout(new java.awt.GridBagLayout());
- statusPanel.setMaximumSize(new java.awt.Dimension(400, 100));
- statusPanel.setMinimumSize(new java.awt.Dimension(400, 100));
- statusPanel.setPreferredSize(new java.awt.Dimension(400, 100));
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 0;
- gridBagConstraints.gridwidth = 1;
- gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
- gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
- gridBagConstraints.weightx = 1.0;
- statusPanel.add(status, gridBagConstraints);
- getContentPane().add(statusPanel, java.awt.BorderLayout.SOUTH);
-
- pack();
- }//GEN-END:initComponents
-
- private void installButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_installButtonActionPerformed
- // TODO add your handling code here:
- }//GEN-LAST:event_installButtonActionPerformed
-
- private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitButtonActionPerformed
- System.exit(1);
- dispose();
- }//GEN-LAST:event_exitButtonActionPerformed
-
- private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
-
- Cvar.Set("cddir", dir);
- FS.setCDDir();
-
- synchronized(this) {
- notifyAll();
- }
- }//GEN-LAST:event_okButtonActionPerformed
-
- private void changeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeButtonActionPerformed
- JFileChooser chooser = new JFileChooser();
- chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
- chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);
- chooser.setMultiSelectionEnabled(false);
- chooser.setDialogTitle("choose a valid baseq2 directory");
- chooser.showDialog(this, "OK");
-
- dir = null;
- try {
- dir = chooser.getSelectedFile().getCanonicalPath();
- } catch (IOException e) {}
- jTextField1.setText(dir);
-
- }//GEN-LAST:event_changeButtonActionPerformed
-
- private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
- System.exit(1);
- dispose();
- }//GEN-LAST:event_formWindowClosing
-
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- new Q2DataDialog().setVisible(true);
- System.out.println("Hi");
- }
-
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton changeButton;
- private javax.swing.JButton exitButton;
- private javax.swing.JButton installButton;
- private Jake2Canvas canvas;
- private javax.swing.JPanel choosePanel;
- private JPanel statusPanel;
- private JLabel status;
- private javax.swing.JTextField jTextField1;
- private javax.swing.JButton okButton;
- // End of variables declaration//GEN-END:variables
-
- private String dir;
-
- void showChooseDialog() {
- getContentPane().remove(statusPanel);
- getContentPane().add(choosePanel, BorderLayout.SOUTH);
- validate();
- repaint();
- }
-
- void showStatus() {
- getContentPane().remove(choosePanel);
- getContentPane().add(statusPanel, BorderLayout.SOUTH);
- validate();
- repaint();
- }
-
- void setStatus(String text) {
- status.setText(text);
- }
-
- void testQ2Data() {
- while (FS.LoadFile("pics/colormap.pcx") == null) {
- showChooseDialog();
-
- try {
- synchronized(this) {
- wait();
- }
- } catch (InterruptedException e) {}
- }
- showStatus();
- }
-
- static class Jake2Canvas extends Canvas {
- private Image image;
- Jake2Canvas() {
- setSize(400, 200);
- image = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/splash.png"));
- while (!Toolkit.getDefaultToolkit().prepareImage(image, -1, -1, null)) {
- try {
- Thread.sleep(50);
- } catch (InterruptedException e) {}
- }
- }
-
-
- /* (non-Javadoc)
- * @see java.awt.Component#paint(java.awt.Graphics)
- */
- public void paint(Graphics g) {
- g.drawImage(image, 0, 0, null);
- }
-
- }
-}
+/*
+ * Q2DataDialog.java
+ *
+ * Created on 17. September 2004, 20:13
+ */
+
+package jake2.qcommon;
+
+import java.awt.*;
+import java.io.*;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Enumeration;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import javax.swing.*;
+
+/**
+ *
+ * @author hoz
+ */
+public class Q2DataDialog extends javax.swing.JDialog {
+
+ /** Creates new form Q2DataDialog */
+ public Q2DataDialog() {
+ super();
+ initComponents();
+
+ DisplayMode mode = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode();
+ int x = (mode.getWidth() - getWidth()) / 2;
+ int y = (mode.getHeight() - getHeight()) / 2;
+ setLocation(x, y);
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ private void initComponents() {//GEN-BEGIN:initComponents
+ java.awt.GridBagConstraints gridBagConstraints;
+
+ choosePanel = new javax.swing.JPanel();
+ statusPanel = new JPanel();
+ status = new JLabel("initializing Jake2...");
+ jTextField1 = new javax.swing.JTextField();
+ changeButton = new javax.swing.JButton();
+ installButton = new javax.swing.JButton();
+ exitButton = new javax.swing.JButton();
+ okButton = new javax.swing.JButton();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
+ setTitle("Jake2 - Bytonic Software");
+
+ setResizable(false);
+ addWindowListener(new java.awt.event.WindowAdapter() {
+ public void windowClosing(java.awt.event.WindowEvent evt) {
+ formWindowClosing(evt);
+ }
+ });
+
+ choosePanel.setLayout(new java.awt.GridBagLayout());
+
+ choosePanel.setMaximumSize(new java.awt.Dimension(400, 100));
+ choosePanel.setMinimumSize(new java.awt.Dimension(400, 100));
+ choosePanel.setPreferredSize(new java.awt.Dimension(400, 100));
+ jTextField1.setPreferredSize(null);
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridwidth = 2;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
+ gridBagConstraints.weightx = 1.0;
+ choosePanel.add(jTextField1, gridBagConstraints);
+
+ changeButton.setText("change");
+ changeButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ changeButtonActionPerformed(evt);
+ }
+ });
+
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 2;
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
+ choosePanel.add(changeButton, gridBagConstraints);
+
+ installButton.setText("Install");
+ installButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ installButtonActionPerformed(evt);
+ }
+ });
+
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ choosePanel.add(installButton, gridBagConstraints);
+
+ exitButton.setText("Exit");
+ exitButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ exitButtonActionPerformed(evt);
+ }
+ });
+
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
+ choosePanel.add(exitButton, gridBagConstraints);
+
+ okButton.setText("OK");
+ okButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ okButtonActionPerformed(evt);
+ }
+ });
+
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 2;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
+ choosePanel.add(okButton, gridBagConstraints);
+
+ //getContentPane().add(choosePanel, java.awt.BorderLayout.SOUTH);
+
+ Jake2Canvas c = new Jake2Canvas();
+ getContentPane().add(c, BorderLayout.CENTER);
+
+ statusPanel.setLayout(new java.awt.GridBagLayout());
+ statusPanel.setMaximumSize(new java.awt.Dimension(400, 100));
+ statusPanel.setMinimumSize(new java.awt.Dimension(400, 100));
+ statusPanel.setPreferredSize(new java.awt.Dimension(400, 100));
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridwidth = 1;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
+ gridBagConstraints.weightx = 1.0;
+ statusPanel.add(status, gridBagConstraints);
+ getContentPane().add(statusPanel, java.awt.BorderLayout.SOUTH);
+
+ pack();
+ }//GEN-END:initComponents
+
+
+ private void installButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_installButtonActionPerformed
+ dir = jTextField1.getText();
+ InstallDialog installer = new InstallDialog(this, dir);
+ dir += "/baseq2";
+ jTextField1.setText(dir);
+
+ new Thread(installer).start();
+
+ }//GEN-LAST:event_installButtonActionPerformed
+
+ private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitButtonActionPerformed
+ System.exit(1);
+ dispose();
+ }//GEN-LAST:event_exitButtonActionPerformed
+
+ private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
+
+ dir = jTextField1.getText();
+ Cvar.Set("cddir", dir);
+ FS.setCDDir();
+
+ synchronized(this) {
+ notifyAll();
+ }
+ }//GEN-LAST:event_okButtonActionPerformed
+
+ private void changeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeButtonActionPerformed
+ JFileChooser chooser = new JFileChooser();
+ chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);
+ chooser.setMultiSelectionEnabled(false);
+ chooser.setDialogTitle("choose a valid baseq2 directory");
+ chooser.showDialog(this, "OK");
+
+ dir = null;
+ try {
+ dir = chooser.getSelectedFile().getCanonicalPath();
+ } catch (IOException e) {}
+ jTextField1.setText(dir);
+
+ }//GEN-LAST:event_changeButtonActionPerformed
+
+ private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
+ System.exit(1);
+ dispose();
+ }//GEN-LAST:event_formWindowClosing
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton changeButton;
+ private javax.swing.JButton exitButton;
+ private javax.swing.JButton installButton;
+ private Jake2Canvas canvas;
+ private javax.swing.JPanel choosePanel;
+ private JPanel statusPanel;
+ private JLabel status;
+ private javax.swing.JTextField jTextField1;
+ private javax.swing.JButton okButton;
+ // End of variables declaration//GEN-END:variables
+
+ private String dir;
+
+ void showChooseDialog() {
+ getContentPane().remove(statusPanel);
+ getContentPane().add(choosePanel, BorderLayout.SOUTH);
+ validate();
+ repaint();
+ }
+
+ void showStatus() {
+ getContentPane().remove(choosePanel);
+ getContentPane().add(statusPanel, BorderLayout.SOUTH);
+ validate();
+ repaint();
+ }
+
+ void setStatus(String text) {
+ status.setText(text);
+ }
+
+ void testQ2Data() {
+ while (FS.LoadFile("pics/colormap.pcx") == null) {
+ showChooseDialog();
+
+ try {
+ synchronized(this) {
+ wait();
+ }
+ } catch (InterruptedException e) {}
+ }
+ showStatus();
+ }
+
+ static class Jake2Canvas extends Canvas {
+ private Image image;
+ Jake2Canvas() {
+ setSize(400, 200);
+ image = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/splash.png"));
+ while (!Toolkit.getDefaultToolkit().prepareImage(image, -1, -1, null)) {
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException e) {}
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.awt.Component#paint(java.awt.Graphics)
+ */
+ public void paint(Graphics g) {
+ g.drawImage(image, 0, 0, null);
+ }
+
+ }
+
+ static class InstallDialog extends JDialog implements Runnable {
+
+ static final String[] locs = {
+ "ftp://ftp.idsoftware.com/idstuff/quake2/q2-314-demo-x86.exe",
+ "ftp://ftp.fu-berlin.de/pc/msdos/games/idgames/idstuff/quake2/q2-314-demo-x86.exe",
+ "ftp://ftp.demon.co.uk/pub/mirrors/idsoftware/quake2/q2-314-demo-x86.exe",
+ "ftp://ftp.fragzone.se/pub/spel/quake2/q2-314-demo-x86.exe" };
+ static byte[] buf = new byte[8192];
+ String destDir;
+
+ JProgressBar progress = new JProgressBar();
+ JLabel label = new JLabel("test");
+ Q2DataDialog parent;
+
+ public InstallDialog(Q2DataDialog parent, String dir) {
+ super(parent);
+
+ initComponents();
+ setResizable(false);
+
+ this.parent = parent;
+ destDir = dir;
+ }
+
+ void initComponents() {
+ progress.setMinimum(0);
+ progress.setMaximum(100);
+ progress.setMinimumSize(new Dimension(200, 20));
+ progress.setMaximumSize(new Dimension(200, 20));
+ progress.setPreferredSize(new Dimension(200, 20));
+ getContentPane().add(progress, BorderLayout.CENTER);
+ getContentPane().add(label, BorderLayout.NORTH);
+ pack();
+ }
+
+ public void run() {
+
+ parent.setEnabled(false);
+ setVisible(true);
+
+ InputStream in = null;
+ OutputStream out = null;
+ File outFile = null;
+
+ label.setText("downloading...");
+
+ try {
+ URL url = new URL(locs[1]);
+ URLConnection conn = url.openConnection();
+ int length = conn.getContentLength();
+ progress.setMaximum(length/1024);
+
+ in = conn.getInputStream();
+
+ outFile = File.createTempFile("Jake2Data", ".zip");
+ System.out.println(outFile.getCanonicalPath());
+ outFile.deleteOnExit();
+ out = new FileOutputStream(outFile);
+
+ copyStream(in, out);
+
+ installData(outFile.getCanonicalPath());
+
+ } catch (Exception e) {}
+
+ try {
+ if (outFile != null) outFile.delete();
+ } catch (Exception e) {}
+
+ setVisible(false);
+ parent.setEnabled(true);
+ parent.okButtonActionPerformed(null);
+ dispose();
+ }
+
+
+ void installData(String filename) {
+ try {
+ ZipFile f = new ZipFile(filename);
+ Enumeration e = f.entries();
+ while (e.hasMoreElements()) {
+ ZipEntry entry = (ZipEntry)e.nextElement();
+ String name = entry.getName();
+ int i;
+ if ((i = name.indexOf("/baseq2")) > -1 && name.indexOf(".dll") == -1) {
+ name = destDir + name.substring(i);
+ File outFile = new File(name);
+ if (entry.isDirectory()) {
+ outFile.mkdirs();
+ } else {
+ label.setText(outFile.getName());
+ progress.setMaximum((int)entry.getSize()/1024);
+ progress.setValue(0);
+ outFile.getParentFile().mkdirs();
+ OutputStream out = new FileOutputStream(outFile);
+ InputStream in = f.getInputStream(entry);
+ copyStream(in, out);
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ void copyStream(InputStream in, OutputStream out) {
+ try {
+ int c = 0;
+ int l;
+ while ((l = in.read(buf)) > 0) {
+ out.write(buf, 0, l);
+ c += l;
+ progress.setValue(c / 1024);
+ //progress.repaint();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ try {
+ in.close();
+ } catch (Exception e) {}
+ try {
+ out.close();
+ } catch (Exception e) {}
+ }
+ }
+
+}