link start!
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.util.jar;
|
||||
|
||||
import com.tridium.util.jar.JarFile;
|
||||
import com.tridium.util.jar.JarURLStreamHandler;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
public class JarEntry
|
||||
extends ZipEntry {
|
||||
JarFile jarFile;
|
||||
ZipEntry entry;
|
||||
|
||||
public String getName() {
|
||||
return this.entry.getName();
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return this.entry.getSize();
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return this.entry.getTime();
|
||||
}
|
||||
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return this.jarFile.zip.getInputStream(this.entry);
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public byte[] read() throws IOException {
|
||||
int n = (int)this.getSize();
|
||||
byte[] byArray = new byte[n];
|
||||
InputStream inputStream = this.getInputStream();
|
||||
try {
|
||||
int n2 = 0;
|
||||
while (n2 < n) {
|
||||
int n3 = inputStream.read(byArray, n2, n - n2);
|
||||
if (n3 < 0) {
|
||||
throw new IOException("Unexpected EOF");
|
||||
}
|
||||
n2 += n3;
|
||||
}
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
Object var5_7 = null;
|
||||
inputStream.close();
|
||||
throw throwable;
|
||||
}
|
||||
{
|
||||
Object var5_8 = null;
|
||||
}
|
||||
inputStream.close();
|
||||
return byArray;
|
||||
}
|
||||
|
||||
public URL getURL() {
|
||||
try {
|
||||
String string = this.jarFile.url + "!/" + this.getName();
|
||||
return new URL("jar", "", -1, string, new JarURLStreamHandler(this));
|
||||
}
|
||||
catch (MalformedURLException malformedURLException) {
|
||||
malformedURLException.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public JarEntry(JarFile jarFile, ZipEntry zipEntry) {
|
||||
super(zipEntry.getName());
|
||||
this.jarFile = jarFile;
|
||||
this.entry = zipEntry;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.util.jar;
|
||||
|
||||
import com.tridium.util.jar.JarEntry;
|
||||
import com.tridium.util.jar.Manifest;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipException;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
public class JarFile {
|
||||
File file;
|
||||
public ZipFile zip;
|
||||
URL url;
|
||||
long openTime;
|
||||
|
||||
public void check() {
|
||||
if (this.file.lastModified() != this.openTime) {
|
||||
try {
|
||||
System.out.println("WARNING: JarFile.reopen: " + this.file);
|
||||
this.zip.close();
|
||||
this.zip = new ZipFile(this.file);
|
||||
this.openTime = this.file.lastModified();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
System.out.println(" " + exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
this.zip.close();
|
||||
this.zip = null;
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return this.file;
|
||||
}
|
||||
|
||||
public URL getFileURL() {
|
||||
return this.url;
|
||||
}
|
||||
|
||||
public Enumeration entries() {
|
||||
this.check();
|
||||
return this.zip.entries();
|
||||
}
|
||||
|
||||
public JarEntry getJarEntry(String string) {
|
||||
this.check();
|
||||
ZipEntry zipEntry = this.zip.getEntry(string);
|
||||
if (zipEntry != null) {
|
||||
return new JarEntry(this, zipEntry);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public URL getResource(String string) {
|
||||
JarEntry jarEntry = this.getJarEntry(string);
|
||||
if (jarEntry != null) {
|
||||
return jarEntry.getURL();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Manifest getManifest() throws IOException {
|
||||
JarEntry jarEntry = this.getJarEntry("META-INF/MANIFEST.MF");
|
||||
if (jarEntry == null) {
|
||||
return null;
|
||||
}
|
||||
InputStream inputStream = jarEntry.getInputStream();
|
||||
Manifest manifest = new Manifest(inputStream);
|
||||
inputStream.close();
|
||||
return manifest;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.file.toString();
|
||||
}
|
||||
|
||||
public JarFile(File file) throws ZipException, IOException {
|
||||
if (!file.exists()) {
|
||||
throw new FileNotFoundException("" + file);
|
||||
}
|
||||
this.file = file;
|
||||
this.zip = new ZipFile(file);
|
||||
this.url = file.toURL();
|
||||
this.openTime = file.lastModified();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.util.jar;
|
||||
|
||||
import com.tridium.util.jar.JarEntry;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
public class JarURLConnection
|
||||
extends URLConnection {
|
||||
private JarEntry entry;
|
||||
|
||||
public int getContentLength() {
|
||||
return (int)this.entry.getSize();
|
||||
}
|
||||
|
||||
public long getLastModified() {
|
||||
return this.entry.getTime();
|
||||
}
|
||||
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return this.entry.getInputStream();
|
||||
}
|
||||
|
||||
public void connect() {
|
||||
}
|
||||
|
||||
public JarURLConnection(URL uRL, JarEntry jarEntry) {
|
||||
super(uRL);
|
||||
this.entry = jarEntry;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.util.jar;
|
||||
|
||||
import com.tridium.util.jar.JarEntry;
|
||||
import com.tridium.util.jar.JarURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLStreamHandler;
|
||||
|
||||
public class JarURLStreamHandler
|
||||
extends URLStreamHandler {
|
||||
private JarEntry entry;
|
||||
|
||||
public URLConnection openConnection(URL uRL) {
|
||||
return new JarURLConnection(uRL, this.entry);
|
||||
}
|
||||
|
||||
public JarURLStreamHandler(JarEntry jarEntry) {
|
||||
this.entry = jarEntry;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,301 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.util.jar;
|
||||
|
||||
import com.tridium.util.CaseInsensitiveStringTable;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class Manifest {
|
||||
public static final String NAME = "META-INF/MANIFEST.MF";
|
||||
private static final int LF = 10;
|
||||
private static final int CR = 13;
|
||||
private static final int COLON = 58;
|
||||
private static final int SPACE = 32;
|
||||
private CaseInsensitiveStringTable mainAttributes;
|
||||
private CaseInsensitiveStringTable attributes;
|
||||
|
||||
public CaseInsensitiveStringTable getMainAttributes() {
|
||||
if (this.mainAttributes == null) {
|
||||
this.mainAttributes = new CaseInsensitiveStringTable();
|
||||
}
|
||||
return this.mainAttributes;
|
||||
}
|
||||
|
||||
public CaseInsensitiveStringTable getAttributes(String string) {
|
||||
if (string.charAt(0) == '/') {
|
||||
string = string.substring(1);
|
||||
}
|
||||
return (CaseInsensitiveStringTable)this.attributes.get(string);
|
||||
}
|
||||
|
||||
public void putAttributes(String string, CaseInsensitiveStringTable caseInsensitiveStringTable) {
|
||||
if (string.charAt(0) == '/') {
|
||||
string = string.substring(1);
|
||||
}
|
||||
this.attributes.put(string, (Object)caseInsensitiveStringTable);
|
||||
}
|
||||
|
||||
public void write(OutputStream outputStream) throws IOException {
|
||||
DataOutputStream dataOutputStream = new DataOutputStream(outputStream);
|
||||
this.write(dataOutputStream, this.mainAttributes);
|
||||
String[] stringArray = this.attributes.keyArray();
|
||||
Object[] objectArray = this.attributes.elementArray();
|
||||
int n = 0;
|
||||
while (n < stringArray.length) {
|
||||
String string = stringArray[n];
|
||||
CaseInsensitiveStringTable caseInsensitiveStringTable = (CaseInsensitiveStringTable)objectArray[n];
|
||||
StringBuffer stringBuffer = new StringBuffer(80);
|
||||
stringBuffer.append("Name: ").append(string).append("\r\n");
|
||||
Manifest.checkContinuation(stringBuffer);
|
||||
dataOutputStream.writeBytes(stringBuffer.toString());
|
||||
this.write(dataOutputStream, caseInsensitiveStringTable);
|
||||
++n;
|
||||
}
|
||||
dataOutputStream.flush();
|
||||
}
|
||||
|
||||
void write(DataOutputStream dataOutputStream, CaseInsensitiveStringTable caseInsensitiveStringTable) throws IOException {
|
||||
String[] stringArray = caseInsensitiveStringTable.keyArray();
|
||||
Object[] objectArray = caseInsensitiveStringTable.elementArray();
|
||||
int n = 0;
|
||||
while (n < stringArray.length) {
|
||||
String string = stringArray[n];
|
||||
String string2 = (String)objectArray[n];
|
||||
StringBuffer stringBuffer = new StringBuffer(80);
|
||||
stringBuffer.append(string).append(": ").append(string2).append("\r\n");
|
||||
Manifest.checkContinuation(stringBuffer);
|
||||
dataOutputStream.writeBytes(stringBuffer.toString());
|
||||
++n;
|
||||
}
|
||||
dataOutputStream.writeBytes("\r\n");
|
||||
}
|
||||
|
||||
static void checkContinuation(StringBuffer stringBuffer) {
|
||||
int n = stringBuffer.length();
|
||||
if (n > 72) {
|
||||
int n2;
|
||||
char[] cArray = stringBuffer.toString().toCharArray();
|
||||
if (cArray[(n2 = cArray.length) - 2] == '\r' && cArray[n2 - 1] == '\n') {
|
||||
n2 -= 2;
|
||||
}
|
||||
stringBuffer.setLength(0);
|
||||
int n3 = 0;
|
||||
while (n3 < n2) {
|
||||
stringBuffer.append(cArray[n3]);
|
||||
if (n3 > 0 && n3 % 71 == 0) {
|
||||
stringBuffer.append("\r\n ");
|
||||
}
|
||||
++n3;
|
||||
}
|
||||
if (stringBuffer.charAt(stringBuffer.length() - 3) == '\r' && stringBuffer.charAt(stringBuffer.length() - 2) == '\n' && stringBuffer.charAt(stringBuffer.length() - 1) == ' ') {
|
||||
stringBuffer.setLength(stringBuffer.length() - 1);
|
||||
} else if (cArray.length != n2) {
|
||||
stringBuffer.append("\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void read(InputStream inputStream) throws IOException {
|
||||
int n;
|
||||
this.mainAttributes = null;
|
||||
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
|
||||
LineInfo lineInfo = new LineInfo();
|
||||
String string = null;
|
||||
String string2 = "";
|
||||
CaseInsensitiveStringTable caseInsensitiveStringTable = new CaseInsensitiveStringTable();
|
||||
String string3 = null;
|
||||
int n2 = 0;
|
||||
while ((n = this.readLine(bufferedInputStream, lineInfo)) >= 0) {
|
||||
++n2;
|
||||
if (n > 72) {
|
||||
Manifest.throwException("Line too long", n2);
|
||||
}
|
||||
if (lineInfo.isSectionBreak()) {
|
||||
this.addAttributes(string3, caseInsensitiveStringTable, n2);
|
||||
caseInsensitiveStringTable = new CaseInsensitiveStringTable();
|
||||
string3 = null;
|
||||
continue;
|
||||
}
|
||||
if (string == null) {
|
||||
string = lineInfo.getKey();
|
||||
string2 = lineInfo.getValue();
|
||||
} else {
|
||||
string2 = string2 + lineInfo.getValue();
|
||||
}
|
||||
if (lineInfo.isNextLineContinuation) continue;
|
||||
if (this.isName(string) && string3 == null) {
|
||||
string3 = string2;
|
||||
} else {
|
||||
this.addAttributeEntry(caseInsensitiveStringTable, string, string2, n2);
|
||||
}
|
||||
string = null;
|
||||
}
|
||||
if (string3 != null || this.mainAttributes == null) {
|
||||
this.addAttributes(string3, caseInsensitiveStringTable, n2);
|
||||
}
|
||||
}
|
||||
|
||||
private final void addAttributes(String string, CaseInsensitiveStringTable caseInsensitiveStringTable, int n) throws IOException {
|
||||
if (this.mainAttributes == null) {
|
||||
this.mainAttributes = caseInsensitiveStringTable;
|
||||
} else {
|
||||
if (string == null) {
|
||||
Manifest.throwException("Section missing Name", n);
|
||||
}
|
||||
this.attributes.put(string, (Object)caseInsensitiveStringTable);
|
||||
}
|
||||
}
|
||||
|
||||
private final void addAttributeEntry(CaseInsensitiveStringTable caseInsensitiveStringTable, String string, String string2, int n) {
|
||||
if (string == null) {
|
||||
return;
|
||||
}
|
||||
caseInsensitiveStringTable.put(string, (Object)string2);
|
||||
}
|
||||
|
||||
private final int readLine(BufferedInputStream bufferedInputStream, LineInfo lineInfo) throws IOException {
|
||||
int n;
|
||||
lineInfo.valuePos = -1;
|
||||
lineInfo.count = 0;
|
||||
byte[] byArray = lineInfo.buf;
|
||||
int n2 = 0;
|
||||
boolean bl = false;
|
||||
do {
|
||||
n = bufferedInputStream.read();
|
||||
if (n2 == 0 && n == -1) {
|
||||
n2 = -1;
|
||||
break;
|
||||
}
|
||||
if (n == 13) {
|
||||
bufferedInputStream.mark(1);
|
||||
n = bufferedInputStream.read();
|
||||
if (n != 10) {
|
||||
bufferedInputStream.reset();
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (n == 10) break;
|
||||
if (bl && n == 32 && lineInfo.valuePos == -1) {
|
||||
lineInfo.valuePos = n2;
|
||||
}
|
||||
boolean bl2 = false;
|
||||
if (n == 58) {
|
||||
bl2 = true;
|
||||
}
|
||||
bl = bl2;
|
||||
byArray[n2++] = (byte)n;
|
||||
} while (byArray.length != n2);
|
||||
bufferedInputStream.mark(1);
|
||||
n = bufferedInputStream.read();
|
||||
boolean bl3 = false;
|
||||
if (n == 32) {
|
||||
bl3 = lineInfo.isNextLineContinuation = true;
|
||||
}
|
||||
if (!lineInfo.isNextLineContinuation) {
|
||||
bufferedInputStream.reset();
|
||||
}
|
||||
lineInfo.count = n2;
|
||||
return n2;
|
||||
}
|
||||
|
||||
private final boolean isName(String string) {
|
||||
if (string.length() != 4) {
|
||||
return false;
|
||||
}
|
||||
char c = string.charAt(0);
|
||||
if (c != 'N' && c != 'n') {
|
||||
return false;
|
||||
}
|
||||
c = string.charAt(1);
|
||||
if (c != 'A' && c != 'a') {
|
||||
return false;
|
||||
}
|
||||
c = string.charAt(2);
|
||||
if (c != 'M' && c != 'm') {
|
||||
return false;
|
||||
}
|
||||
c = string.charAt(3);
|
||||
return c == 'E' || c == 'e';
|
||||
}
|
||||
|
||||
static void throwException(String string, int n) throws IOException {
|
||||
if (n != -1) {
|
||||
throw new IOException(string + " [line " + n + ']');
|
||||
}
|
||||
throw new IOException(string);
|
||||
}
|
||||
|
||||
public static void main(String[] stringArray) throws IOException {
|
||||
if (stringArray.length < 1) {
|
||||
System.out.println("usage: Manifest <filename>");
|
||||
return;
|
||||
}
|
||||
System.out.println("--- \"" + stringArray[0] + "\" ---");
|
||||
Manifest manifest = new Manifest(new FileInputStream(stringArray[0]));
|
||||
manifest.write(System.out);
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.attributes = new CaseInsensitiveStringTable();
|
||||
}
|
||||
|
||||
public Manifest() {
|
||||
this.this();
|
||||
}
|
||||
|
||||
public Manifest(InputStream inputStream) throws IOException {
|
||||
this.this();
|
||||
this.read(inputStream);
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
static class LineInfo {
|
||||
int valuePos;
|
||||
byte[] buf;
|
||||
int count;
|
||||
boolean isNextLineContinuation;
|
||||
|
||||
String getKey() {
|
||||
if (this.valuePos == -1) {
|
||||
return new String(this.buf, 0, 0, this.count);
|
||||
}
|
||||
return new String(this.buf, 0, 0, this.valuePos - 1);
|
||||
}
|
||||
|
||||
String getValue() {
|
||||
if (this.valuePos == -1) {
|
||||
return new String(this.buf, 0, this.count);
|
||||
}
|
||||
return new String(this.buf, 0, this.valuePos + 1, this.count - this.valuePos - 1);
|
||||
}
|
||||
|
||||
boolean isSectionBreak() {
|
||||
boolean bl = false;
|
||||
if (this.count == 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.valuePos = -1;
|
||||
this.buf = new byte[80];
|
||||
}
|
||||
|
||||
LineInfo() {
|
||||
this.this();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user