mirror of
https://github.com/GTNewHorizons/CodeChickenCore.git
synced 2026-11-26 23:22:56 +00:00
use ZipFile instead of ZipInputStream in ClassDiscoverer (#25)
This commit is contained in:
1 parent
22dfc1360e
commit
4e7eb37f3f
1 file changed
+13
-16
@@ -1,13 +1,13 @@
|
|||||||
package codechicken.core;
|
package codechicken.core;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Enumeration;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
import net.minecraft.launchwrapper.Launch;
|
import net.minecraft.launchwrapper.Launch;
|
||||||
|
|
||||||
@@ -114,21 +114,18 @@ public class ClassDiscoverer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void readFromZipFile(File file) throws IOException {
|
private void readFromZipFile(File file) throws IOException {
|
||||||
FileInputStream fileinputstream = new FileInputStream(file);
|
try (ZipFile zipFile = new ZipFile(file)) {
|
||||||
ZipInputStream zipinputstream = new ZipInputStream(fileinputstream);
|
Enumeration<? extends ZipEntry> zipEntries = zipFile.entries();
|
||||||
do {
|
while (zipEntries.hasMoreElements()) {
|
||||||
ZipEntry zipentry = zipinputstream.getNextEntry();
|
ZipEntry zipentry = zipEntries.nextElement();
|
||||||
if (zipentry == null) {
|
String fullname = zipentry.getName().replace('\\', '/');
|
||||||
break;
|
int pos = fullname.lastIndexOf('/');
|
||||||
|
String name = pos == -1 ? fullname : fullname.substring(pos + 1);
|
||||||
|
if (!zipentry.isDirectory() && matcher.matches(name)) {
|
||||||
|
checkAddClass(fullname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String fullname = zipentry.getName().replace('\\', '/');
|
}
|
||||||
int pos = fullname.lastIndexOf('/');
|
|
||||||
String name = pos == -1 ? fullname : fullname.substring(pos + 1);
|
|
||||||
if (!zipentry.isDirectory() && matcher.matches(name)) {
|
|
||||||
checkAddClass(fullname);
|
|
||||||
}
|
|
||||||
} while (true);
|
|
||||||
fileinputstream.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readFromDirectory(File directory, File basedirectory) {
|
private void readFromDirectory(File directory, File basedirectory) {
|
||||||
|
|||||||
Reference in new issue
Block a user