AdobeJarSupport.java
2.77 KB
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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.commons.io.FileUtils
* org.apache.commons.io.IOUtils
*/
package com.adobe.aemds.bedrock.installer.internal;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
public class AdobeJarSupport {
private JarInputStream jarStream = null;
public AdobeJarSupport(InputStream inStream) throws IOException {
this.jarStream = new JarInputStream(new BufferedInputStream(inStream));
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
private void unjar(File inDirectory, InputStream inJarStream, JarEntry inEntryName, boolean setSharedXbit) throws IOException {
File destFile = null;
int pos = inEntryName.getName().lastIndexOf(47);
if (pos == -1) {
pos = inEntryName.getName().lastIndexOf(File.separator);
}
if (pos != -1) {
String path = inEntryName.getName().substring(0, pos);
File destDir = new File(inDirectory, path);
FileUtils.forceMkdir((File)destDir);
destFile = new File(inDirectory, inEntryName.getName());
} else {
destFile = new File(inDirectory, inEntryName.getName());
}
if (!destFile.isDirectory()) {
block9 : {
if (destFile.exists() && destFile.canWrite() || destFile.createNewFile()) {
FileOutputStream destStream = null;
try {
destStream = new FileOutputStream(destFile);
if (inJarStream != null) {
IOUtils.copyLarge((InputStream)inJarStream, (OutputStream)destStream);
}
break block9;
}
finally {
IOUtils.closeQuietly((OutputStream)destStream);
}
}
throw new IOException("Can't unjar file '" + inEntryName.getName() + "' into directory '" + inDirectory + "'");
}
destFile.setLastModified(inEntryName.getTime());
}
}
public void extractAll(File directory, boolean setSharedXbit) throws IOException {
JarEntry entry;
FileUtils.forceMkdir((File)directory);
while ((entry = this.jarStream.getNextJarEntry()) != null) {
this.unjar(directory, this.jarStream, entry, setSharedXbit);
}
}
public void close() throws IOException {
this.jarStream.close();
}
}