From f6b8eeb29ecf96b0b67545f660766b8cee285887 Mon Sep 17 00:00:00 2001 From: Downforce Agent Date: Sun, 30 Jun 2024 06:49:00 -0500 Subject: [PATCH] fix ghost files on windows --- src/MissPiggy.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/MissPiggy.java b/src/MissPiggy.java index da24779..51b604e 100644 --- a/src/MissPiggy.java +++ b/src/MissPiggy.java @@ -47,6 +47,8 @@ import static java.nio.file.StandardCopyOption.*; import static javax.swing.WindowConstants.EXIT_ON_CLOSE; public class MissPiggy implements ActionListener { + private final String sl = File.separator; + BufferedImage windowIcon; JFrame frame = new JFrame(); JPanel frameContainer; @@ -191,8 +193,11 @@ public class MissPiggy implements ActionListener { 06/29/24 - also skip files that were manually removed but remain in the list */ + + File mod = new File(System.getProperty("user.home") + sl + ".firestar" + sl + "mods" + sl + s.substring(s.indexOf("=") + 1).trim()); + if (s.split("=")[0].matches("[0-9]+=*") && - new File(System.getProperty("user.home") + "/.firestar/mods/" + s.substring(s.indexOf("=") + 1)).exists()) { + mod.exists()) { //append mod to list from substring Main.Mod m = new Main().new Mod(); m.path = s.substring(s.indexOf("=") + 1); @@ -201,7 +206,7 @@ public class MissPiggy implements ActionListener { //get json metadata from zip comment JSONObject metadata; try { - metadata = new JSONObject(new ZipFile(System.getProperty("user.home") + "/.firestar/mods/" + m.path).getComment()); + metadata = new JSONObject(new ZipFile(System.getProperty("user.home") + sl + ".firestar" + sl + "mods" + sl + m.path.trim()).getComment()); if (metadata.has("friendlyName")) {m.friendlyName = metadata.get("friendlyName").toString();} else {m.friendlyName = m.path;} if (metadata.has("description")) {m.description = metadata.get("description").toString();} if (metadata.has("version")) {m.version = Integer.parseInt(metadata.get("version").toString());} @@ -213,6 +218,7 @@ public class MissPiggy implements ActionListener { Main.Mods.add(m); } catch (Exception e) { System.out.println("WARNING: mod entry for " + s + " was found but does not contain valid JSON metadata. skipping"); + System.out.println(e.getMessage()); } } else { if (!s.isEmpty()) {System.out.println("WARNING: mod entry for " + s + " doesn't actually exist. skipping");}