From 43aebf9f843764354b55d131be0d3d825cc04c02 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 13 Apr 2019 10:01:21 +0700 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20=D0=94=D0=B8=D0=BD=D0=B0=D0=BC?= =?UTF-8?q?=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=B0=D1=8F=20=D0=B3=D0=B5=D0=BD?= =?UTF-8?q?=D0=B5=D1=80=D0=B0=D1=86=D0=B8=D1=8F=20=D0=BC=D0=B0=D0=BF=D0=BF?= =?UTF-8?q?=D0=B8=D0=BD=D0=B3=D0=BE=D0=B2=20=D0=B4=D0=BB=D1=8F=20ScriptEng?= =?UTF-8?q?ine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/gravit/utils/helper/JarHelper.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/libLauncher/src/main/java/ru/gravit/utils/helper/JarHelper.java b/libLauncher/src/main/java/ru/gravit/utils/helper/JarHelper.java index f5492329..686ed2dd 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/helper/JarHelper.java +++ b/libLauncher/src/main/java/ru/gravit/utils/helper/JarHelper.java @@ -4,7 +4,6 @@ import java.nio.file.Path; import java.util.HashMap; import java.util.Map; -import java.util.jar.JarInputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -28,26 +27,29 @@ public static void zipWalk(ZipInputStream input, ZipWalkCallback callback) throw e = input.getNextEntry(); } } - public static void jarWalk(JarInputStream input, JarWalkCallback callback) throws IOException + public static void jarWalk(ZipInputStream input, JarWalkCallback callback) throws IOException { - zipWalk(input, (in, e) -> { + ZipEntry e = input.getNextEntry(); + while (e != null) + { String filename = e.getName(); if(filename.endsWith(".class")) { String classFull = filename.replaceAll("/", ".").substring(0, filename.length() - ".class".length()); - String clazz = classFull.substring(classFull.lastIndexOf('.')); - callback.process(in,e, classFull, clazz); + String clazz = classFull.substring(classFull.lastIndexOf('.')+1); + callback.process(input,e, classFull, clazz); } - }); + e = input.getNextEntry(); + } } - public static Map jarMap(JarInputStream input, boolean overwrite) throws IOException + public static Map jarMap(ZipInputStream input, boolean overwrite) throws IOException { Map map = new HashMap<>(); jarMap(input, map, overwrite); return map; } - public static void jarMap(JarInputStream input, Map map, boolean overwrite) throws IOException + public static void jarMap(ZipInputStream input, Map map, boolean overwrite) throws IOException { jarWalk(input, (in, e, classFull, clazz) -> { if(overwrite) map.put(clazz, classFull); @@ -56,14 +58,14 @@ public static void jarMap(JarInputStream input, Map map, boolean } public static Map jarMap(Path file, boolean overwrite) throws IOException { - try(JarInputStream inputStream = new JarInputStream(IOHelper.newZipInput(file))) + try(ZipInputStream inputStream = IOHelper.newZipInput(file)) { return jarMap(inputStream,overwrite); } } public static void jarMap(Path file, Map map, boolean overwrite) throws IOException { - try(JarInputStream inputStream = new JarInputStream(IOHelper.newZipInput(file))) + try(ZipInputStream inputStream = IOHelper.newZipInput(file)) { jarMap(inputStream, map,overwrite); }