Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
apkreader committed Oct 16, 2020
1 parent a4d29ce commit 0ea60a7
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
.classpath
.project
.DS_Store
14 changes: 14 additions & 0 deletions src/de/xbrowniecodez/classfixer/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package de.xbrowniecodez.classfixer;

import de.xbrowniecodez.classfixer.processor.Processor;
import de.xbrowniecodez.classfixer.utils.Utils;

public class Main {
public static void main(String args[]) throws Throwable {
Utils.log("Starting ClassFixer v1.0 by xBrownieCodez");
new Processor(args[0]);
Utils.log("Done! Output: " + args[0].replace(".jar", "") + "-Output.jar");
}


}
18 changes: 18 additions & 0 deletions src/de/xbrowniecodez/classfixer/methods/ClassFolders.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package de.xbrowniecodez.classfixer.methods;

import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;

import de.xbrowniecodez.classfixer.utils.Utils;

public class ClassFolders {
public void process(ZipFile zip, ZipEntry zipEntry, ZipOutputStream out) throws Throwable {
if (zipEntry.isDirectory() && zipEntry.getName().endsWith(".class/")) {
ZipEntry newEntry = new ZipEntry(zipEntry.getName().replace(".class/", ".class"));
newEntry.setTime(System.currentTimeMillis());
out.putNextEntry(newEntry);
Utils.writeToFile(out, zip.getInputStream(zipEntry));
}
}
}
30 changes: 30 additions & 0 deletions src/de/xbrowniecodez/classfixer/processor/Processor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package de.xbrowniecodez.classfixer.processor;

import java.io.File;
import java.io.FileOutputStream;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;

import de.xbrowniecodez.classfixer.methods.ClassFolders;
import de.xbrowniecodez.classfixer.utils.Utils;

public class Processor {
public Processor(String input) throws Throwable {
Utils.log("Processing...");
File file = new File(input);
ZipFile zip = new ZipFile(file);
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(input.replace(".jar", "") + "-Output.jar"));
Enumeration<? extends ZipEntry> entries2 = zip.entries();
while (entries2.hasMoreElements()) {
ZipEntry zipEntry = entries2.nextElement();
ClassFolders classFolder = new ClassFolders();
classFolder.process(zip, zipEntry, out);
}
zip.close();
out.close();

}

}
24 changes: 24 additions & 0 deletions src/de/xbrowniecodez/classfixer/utils/Utils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package de.xbrowniecodez.classfixer.utils;

import java.io.InputStream;
import java.util.zip.ZipOutputStream;

public class Utils {
public static void writeToFile(ZipOutputStream outputStream, InputStream inputStream) throws Throwable {
byte[] buffer = new byte[4096];
try {
while (inputStream.available() > 0) {
int data = inputStream.read(buffer);
outputStream.write(buffer, 0, data);
}
} finally {
inputStream.close();
outputStream.closeEntry();
}
}

public static void log(String string) {
System.out.print("[ClassFixer] "+string + "\n");
}

}

0 comments on commit 0ea60a7

Please sign in to comment.