// // Source code recreated from a .class file by IntelliJ IDEA // (powered by FernFlower decompiler) // package org.jeecg.modules.doc.component; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import net.sf.sevenzipjbinding.ExtractAskMode; import net.sf.sevenzipjbinding.ExtractOperationResult; import net.sf.sevenzipjbinding.IArchiveExtractCallback; import net.sf.sevenzipjbinding.IInArchive; import net.sf.sevenzipjbinding.ISequentialOutStream; import net.sf.sevenzipjbinding.PropID; import net.sf.sevenzipjbinding.SevenZipException; public class ExtractCallback implements IArchiveExtractCallback { private int index; private IInArchive inArchive; private String ourDir; public ExtractCallback(IInArchive inArchive, String ourDir) { this.inArchive = inArchive; this.ourDir = ourDir; } public void setCompleted(long arg0) throws SevenZipException { } public void setTotal(long arg0) throws SevenZipException { } public ISequentialOutStream getStream(int index, ExtractAskMode extractAskMode) throws SevenZipException { this.index = index; String path = (String)this.inArchive.getProperty(index, PropID.PATH); boolean isFolder = (Boolean)this.inArchive.getProperty(index, PropID.IS_FOLDER); return (data) -> { try { if (!isFolder) { File file = new File(this.ourDir + File.separator + path); save2File(file, data); } } catch (Exception var5) { var5.printStackTrace(); } return data.length; }; } public void prepareOperation(ExtractAskMode arg0) throws SevenZipException { } public void setOperationResult(ExtractOperationResult extractOperationResult) throws SevenZipException { } public static boolean save2File(File file, byte[] msg) { OutputStream fos = null; boolean var4; try { File parent = file.getParentFile(); if (parent.exists() || parent.mkdirs()) { fos = new FileOutputStream(file, true); fos.write(msg); fos.flush(); var4 = true; return var4; } var4 = false; return var4; } catch (FileNotFoundException var17) { var17.printStackTrace(); var4 = false; return var4; } catch (IOException var18) { var18.printStackTrace(); var4 = false; } finally { try { fos.close(); } catch (IOException var16) { var16.printStackTrace(); } } return var4; } }