zhuguifei
2025-04-28 442928123f63ee497d766f9a7a14f0a6ee067e25
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//
// 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;
    }
}