Compare commits

...

6 Commits

3 changed files with 26 additions and 9 deletions

3
.gitignore vendored
View File

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

View File

@ -17,6 +17,7 @@
*/
import net.lingala.zip4j.ZipFile;
import net.lingala.zip4j.util.FileUtils;
import javax.imageio.ImageIO;
import javax.swing.*;
@ -274,6 +275,7 @@ public class Gonzo {
boolean one = new File(Main.outpath).mkdirs();
boolean two;
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));}
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);
@ -286,11 +288,9 @@ public class Gonzo {
return;
}
try {
Process p;
if (!Main.windows) {p = Runtime.getRuntime().exec(new String[]{"bash","-c","rm -rf " + System.getProperty("user.home") + "/.firestar/temp/"});} // Scary!
else {p = Runtime.getRuntime().exec(new String[]{"rmdir", new String(System.getProperty("user.home") + "/.firestar/temp/").replace("/", "\\").replace("\\", "\\\\"), "/s", "/q"});}
//new File(System.getProperty("user.home") + "/.firestar/temp/").delete();
} catch (IOException e) {
File tmp = new File(System.getProperty("user.home") + "/.firestar/temp/");
deleteDir(tmp);
} catch (Exception e) {
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());
}
@ -345,4 +345,16 @@ public class Gonzo {
}
}
}
private 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
*/
File mod = new File(System.getProperty("user.home") + "/.firestar/mods/" + 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);
m.path = s.substring(s.indexOf("=") + 1).trim();
System.out.println("found file " + m.path);
//get json metadata from zip comment
@ -213,6 +216,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");}
@ -240,7 +244,7 @@ public class MissPiggy implements ActionListener {
System.out.println("Initializing blacklist from file with length of " + bListArray.length + " units"); //debug
for (String s : bListArray) {
for (Main.Mod m : Main.Mods) {
if (s.equals(m.path)) {
if (s.trim().equals(m.path)) {
m.enabled = false;
}
}