8 Commits

4 changed files with 28 additions and 15 deletions

3
.gitignore vendored
View File

@@ -26,4 +26,5 @@ bin/
.vscode/ .vscode/
### Mac OS ### ### Mac OS ###
.DS_Store .DS_Store
/firestar.zip

View File

@@ -17,6 +17,7 @@
*/ */
import net.lingala.zip4j.ZipFile; import net.lingala.zip4j.ZipFile;
import net.lingala.zip4j.util.FileUtils;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.*; import javax.swing.*;
@@ -274,6 +275,7 @@ public class Gonzo {
boolean one = new File(Main.outpath).mkdirs(); boolean one = new File(Main.outpath).mkdirs();
boolean two; boolean two;
System.out.println("created export folder: " + one); System.out.println("created export folder: " + one);
if (new File(Main.outpath + oArcTarget).exists()) {System.out.println("deleting existing file: " + Main.outpath + oArcTarget); new File(Main.outpath + oArcTarget).delete();} //hackjob
if (!Main.windows) {two = new File(System.getProperty("user.home") + "/.firestar/temp/" + oArcTarget).renameTo(new File(Main.outpath + oArcTarget));} if (!Main.windows) {two = new File(System.getProperty("user.home") + "/.firestar/temp/" + oArcTarget).renameTo(new File(Main.outpath + oArcTarget));}
else {two = new File(System.getProperty("user.home") + "\\.firestar\\temp\\" + oArcTarget).renameTo(new File(Main.outpath + oArcTarget));} else {two = new File(System.getProperty("user.home") + "\\.firestar\\temp\\" + oArcTarget).renameTo(new File(Main.outpath + oArcTarget));}
System.out.println("moved file to destination: " + two); System.out.println("moved file to destination: " + two);
@@ -286,11 +288,9 @@ public class Gonzo {
return; return;
} }
try { try {
Process p; File tmp = new File(System.getProperty("user.home") + "/.firestar/temp/");
if (!Main.windows) {p = Runtime.getRuntime().exec(new String[]{"bash","-c","rm -rf " + System.getProperty("user.home") + "/.firestar/temp/"});} // Scary! Main.deleteDir(tmp);
else {p = Runtime.getRuntime().exec(new String[]{"rmdir", new String(System.getProperty("user.home") + "/.firestar/temp/").replace("/", "\\").replace("\\", "\\\\"), "/s", "/q"});} } catch (Exception e) {
//new File(System.getProperty("user.home") + "/.firestar/temp/").delete();
} catch (IOException e) {
System.out.println("WARNING: Temporary files may not have been properly cleared.\n" + e.getMessage()); System.out.println("WARNING: Temporary files may not have been properly cleared.\n" + e.getMessage());
consoleDisplay.append("WARNING: Temporary files may not have been properly cleared.\n" + e.getMessage()); consoleDisplay.append("WARNING: Temporary files may not have been properly cleared.\n" + e.getMessage());
} }

View File

@@ -25,7 +25,7 @@ import javax.swing.JOptionPane;
public class Main { public class Main {
// Build Information // Build Information
public static final String vstr = "Beta 1"; public static final String vstr = "Beta 4";
public static final String vcode = "Natasha"; public static final String vcode = "Natasha";
public static final int vint = 0; public static final int vint = 0;
@@ -128,4 +128,16 @@ public class Main {
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }
} }
public static void deleteDir(File file) { // https://stackoverflow.com/a/29175213/9259829
File[] contents = file.listFiles();
if (contents != null) {
for (File f : contents) {
if (! Files.isSymbolicLink(f.toPath())) {
deleteDir(f);
}
}
}
file.delete();
}
} }

View File

@@ -191,11 +191,14 @@ public class MissPiggy implements ActionListener {
06/29/24 - also skip files that were manually removed but remain in the list 06/29/24 - also skip files that were manually removed but remain in the list
*/ */
File mod = new File(System.getProperty("user.home") + "/.firestar/mods/" + s.substring(s.indexOf("=") + 1).trim());
if (s.split("=")[0].matches("[0-9]+=*") && 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 //append mod to list from substring
Main.Mod m = new Main().new Mod(); Main.Mod m = new Main().new Mod();
m.path = s.substring(s.indexOf("=") + 1); m.path = s.substring(s.indexOf("=") + 1).trim();
System.out.println("found file " + m.path); System.out.println("found file " + m.path);
//get json metadata from zip comment //get json metadata from zip comment
@@ -213,6 +216,7 @@ public class MissPiggy implements ActionListener {
Main.Mods.add(m); Main.Mods.add(m);
} catch (Exception e) { } catch (Exception e) {
System.out.println("WARNING: mod entry for " + s + " was found but does not contain valid JSON metadata. skipping"); System.out.println("WARNING: mod entry for " + s + " was found but does not contain valid JSON metadata. skipping");
System.out.println(e.getMessage());
} }
} else { } else {
if (!s.isEmpty()) {System.out.println("WARNING: mod entry for " + s + " doesn't actually exist. skipping");} if (!s.isEmpty()) {System.out.println("WARNING: mod entry for " + s + " doesn't actually exist. skipping");}
@@ -240,7 +244,7 @@ public class MissPiggy implements ActionListener {
System.out.println("Initializing blacklist from file with length of " + bListArray.length + " units"); //debug System.out.println("Initializing blacklist from file with length of " + bListArray.length + " units"); //debug
for (String s : bListArray) { for (String s : bListArray) {
for (Main.Mod m : Main.Mods) { for (Main.Mod m : Main.Mods) {
if (s.equals(m.path)) { if (s.trim().equals(m.path)) {
m.enabled = false; m.enabled = false;
} }
} }
@@ -392,11 +396,7 @@ public class MissPiggy implements ActionListener {
int result = JOptionPane.showConfirmDialog(frame, "Do you really want to delete all mods?", "Remove All", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); int result = JOptionPane.showConfirmDialog(frame, "Do you really want to delete all mods?", "Remove All", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
if (result == JOptionPane.YES_OPTION) { if (result == JOptionPane.YES_OPTION) {
for (Main.Mod entry : Main.Mods) { Main.deleteDir(new File(System.getProperty("user.home") + "/.firestar/mods/"));
new File(System.getProperty("user.home") + "/.firestar/mods/" + entry.path).delete();
}
new File(System.getProperty("user.home") + "/.firestar/mods/index").delete();
Main.Mods.clear(); Main.Mods.clear();
InitializeModListStructure(); InitializeModListStructure();