From f0c75d4b3cf65ab6a516e32e25a2928823bc3bb6 Mon Sep 17 00:00:00 2001 From: yanghuanyu <991390114@qq.com> Date: Fri, 31 Dec 2021 15:05:30 +0800 Subject: [PATCH] fix: unpackInternal bug --- src/main/entry/org/bdware/sc/YJSPacker.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/entry/org/bdware/sc/YJSPacker.java b/src/main/entry/org/bdware/sc/YJSPacker.java index b3f361e..d4b5ed5 100644 --- a/src/main/entry/org/bdware/sc/YJSPacker.java +++ b/src/main/entry/org/bdware/sc/YJSPacker.java @@ -275,12 +275,21 @@ public class YJSPacker { if (!parent.exists()) { LOGGER.trace("create directory " + parent.getAbsolutePath() + ": " + parent.mkdirs()); } - FileOutputStream fout = new FileOutputStream(target); - for (int k; (k = zin.read(buff)) > 0; ) { - fout.write(buff, 0, k); + if (!target.exists()) { + if (entry.isDirectory()) { + target.mkdirs(); + } else { + target.createNewFile(); + } + } + if (!entry.isDirectory()) { + FileOutputStream fout = new FileOutputStream(target); + for (int k; (k = zin.read(buff)) > 0; ) { + fout.write(buff, 0, k); + } + fout.close(); + zin.closeEntry(); } - fout.close(); - zin.closeEntry(); } zin.close(); } catch (Exception e) {