-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
|
||
} |