home *** CD-ROM | disk | FTP | other *** search
- package com.sfs.iavazip;
-
- import com.sfs.awt.treeview.Folder;
- import com.sfs.awt.treeview.Item;
- import com.sfs.awt.treeview.RootFolder;
- import com.sfs.debug.Debug;
- import com.sfs.util.WildCard;
- import java.awt.Dialog;
- import java.awt.Window;
- import java.io.File;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.util.Enumeration;
- import java.util.Vector;
- import java.util.zip.ZipEntry;
-
- class processExtract extends processDlg {
- ExtractDialog _Extract;
- WildCard EntryRules;
- Boolean overWrite;
- // $FF: renamed from: os java.io.FileOutputStream
- FileOutputStream field_0;
- // $FF: renamed from: is java.io.InputStream
- InputStream field_1;
-
- public void processCanceled() {
- super.thread.stop();
-
- try {
- if (this.field_0 != null) {
- this.field_0.close();
- }
-
- if (this.field_1 != null) {
- this.field_1.close();
- }
- } catch (IOException var1) {
- }
-
- this._Extract.mainApp.setDefaultCursor();
- super.mainApp.showStatus("Extract Files canceled.");
- }
-
- protected void extractEntry(ZipEntry var1) {
- Debug.Info(var1.getName());
- String var2 = var1.getName();
- String var4 = var2;
- int var3;
- if ((var3 = var2.lastIndexOf(47)) != -1) {
- var4 = var2.substring(var3 + 1, var2.length());
- }
-
- if (this.EntryRules.isAccepted(var4)) {
- if (!Boolean.valueOf(super.mainApp.properties.getProperty("Extract.useFoldernames"))) {
- var2 = var4;
- } else {
- var2 = var2.replace('/', File.separatorChar);
- }
-
- String var5 = super.mainApp.properties.getProperty("Extract.Destination") + File.separator + var2;
- if (Boolean.valueOf(super.mainApp.properties.getProperty("Extract.useFoldernames")) && var2.indexOf(File.separatorChar) != -1) {
- String var6 = var5.substring(0, var5.lastIndexOf(File.separatorChar));
- File var7 = new File(var6);
- var7.mkdirs();
- }
-
- File var11 = new File(var5);
- if (var11.exists()) {
- if (this.overWrite) {
- var11.delete();
- } else {
- OverwriteFileDialog var12 = new OverwriteFileDialog(this._Extract.mainApp, var1, var11);
- switch (var12.doModal()) {
- case 1:
- this.overWrite = new Boolean("true");
- case 0:
- var11.delete();
- case 2:
- default:
- break;
- case 3:
- return;
- }
- }
- }
-
- try {
- this.field_0 = new FileOutputStream(var5);
- this.field_1 = super.mainApp.zipFile.getInputStream(var1);
- byte[] var13 = new byte[1024];
-
- int var8;
- while((var8 = this.field_1.read(var13)) != -1) {
- this.field_0.write(var13, 0, var8);
- }
-
- this.field_0.close();
- } catch (IOException var9) {
- }
- }
- }
-
- public void run() {
- int var1 = 0;
- super.mainApp.showStatus("Extracting files");
- this.overWrite = Boolean.valueOf(super.mainApp.properties.getProperty("Extract.overWrite"));
- boolean var2 = Boolean.valueOf(super.mainApp.properties.getProperty("Extract.allFiles"));
- RootFolder var3 = super.mainApp.tw.Root;
- if (!((Item)var3).isSelected() && super.mainApp.tw.Root.getCaretItem() != var3) {
- super.mainApp.tw.Root.getCaretItem().setSelected(true);
- } else {
- ((Item)var3).setSelected(false);
- var2 = true;
- }
-
- if (var2) {
- ((processDlg)this).showStatus("reading zip-entries ...");
-
- for(Enumeration var4 = super.mainApp.zipFile.entries(); var4.hasMoreElements(); ++var1) {
- ZipEntry var5 = (ZipEntry)var4.nextElement();
- String var6 = var5.getName();
- int var7;
- if ((var7 = var6.lastIndexOf("/")) != -1) {
- var6 = var6.substring(var7 + 1, var6.length());
- }
-
- if (this.EntryRules.isAccepted(var6)) {
- }
- }
-
- super.pb.setMaximum((float)var1);
- Enumeration var12 = super.mainApp.zipFile.entries();
- int var14 = 0;
-
- while(super.notCanceled && var12.hasMoreElements()) {
- ZipEntry var16 = (ZipEntry)var12.nextElement();
- ((processDlg)this).showStatus("extract " + var16.getName());
- super.pb.setProgress((float)(var14++));
- this.extractEntry(var16);
-
- try {
- Thread.sleep(15L);
- } catch (InterruptedException var11) {
- }
- }
- } else {
- Debug.Info("only selected files");
- Vector var13 = super.mainApp.tw.Root.Rows;
- Vector var15 = new Vector();
- ((processDlg)this).showStatus("building export list ...");
-
- for(int var17 = 0; var17 < var13.size(); ++var17) {
- Item var19 = (Item)var13.elementAt(var17);
- if (var19.isSelected() && !(var19 instanceof Folder) && this.EntryRules.isAccepted(var19.getName())) {
- ++var1;
- var15.addElement(var19);
- }
- }
-
- super.pb.setMaximum((float)var1);
-
- for(int var18 = 0; super.notCanceled && var18 < var15.size(); ++var18) {
- Item var20 = (Item)var15.elementAt(var18);
- super.pb.setProgress((float)var18);
- if (var20.isSelected() && !(var20 instanceof Folder)) {
- String var8;
- ZipEntry var9 = super.mainApp.zipFile.getEntry(var8 = ((ZipEntry)var20.getContent()).getName());
- ((processDlg)this).showStatus("extract " + var8);
- this.extractEntry(var9);
- }
-
- try {
- Thread.sleep(15L);
- } catch (InterruptedException var10) {
- }
- }
- }
-
- super.mainApp.showStatus("Extract " + Integer.toString(var1) + " files completed.");
- ((Window)this).dispose();
- }
-
- public processExtract(ExtractDialog var1) {
- super(var1.mainApp, "Extract Files ...");
- this._Extract = var1;
- this.EntryRules = new WildCard(var1.Files.getText(), 1);
- ((Dialog)this).setResizable(true);
- }
- }
-