diff --git a/src/main/java/de/mas/wiiu/jnus/fuse_wiiu/implementation/WUDFuseContainer.java b/src/main/java/de/mas/wiiu/jnus/fuse_wiiu/implementation/WUDFuseContainer.java index c2c6fb4..a363ad2 100644 --- a/src/main/java/de/mas/wiiu/jnus/fuse_wiiu/implementation/WUDFuseContainer.java +++ b/src/main/java/de/mas/wiiu/jnus/fuse_wiiu/implementation/WUDFuseContainer.java @@ -2,18 +2,15 @@ package de.mas.wiiu.jnus.fuse_wiiu.implementation; import java.io.File; import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; import java.text.ParseException; import java.util.ArrayList; import java.util.List; import java.util.Optional; -import org.apache.commons.io.FilenameUtils; - import de.mas.wiiu.jnus.WUDLoader; import de.mas.wiiu.jnus.fuse_wiiu.Settings; import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseDirectory; +import de.mas.wiiu.jnus.fuse_wiiu.utils.WUDUtils; import de.mas.wiiu.jnus.implementations.wud.parser.WUDInfo; import de.mas.wiiu.jnus.interfaces.FSTDataProvider; import lombok.val; @@ -28,7 +25,7 @@ public class WUDFuseContainer extends GroupFuseContainer { @Override protected void doInit() { - Optional WUDInfoOpt = loadWUDInfo(input); + Optional WUDInfoOpt = WUDUtils.loadWUDInfo(input); if (WUDInfoOpt.isPresent()) { parseContents(WUDInfoOpt.get()); } else { @@ -36,35 +33,6 @@ public class WUDFuseContainer extends GroupFuseContainer { } } - private Optional loadWUDInfo(File file) { - String FSfilename = file.getName(); - String basename = FilenameUtils.getBaseName(FSfilename); - File keyFile = new File(file.getParent() + File.separator + basename + ".key"); - - if (!keyFile.exists() && Settings.disckeyPath != null) { - System.out.println(".key not found at " + keyFile.getAbsolutePath()); - keyFile = new File(Settings.disckeyPath.getAbsoluteFile() + File.separator + basename + ".key"); - if (!keyFile.exists()) { - System.out.println(".key not found at " + keyFile.getAbsolutePath()); - } - } - - try { - if (keyFile.exists()) { - return Optional.of(WUDLoader.load(file.getAbsolutePath(), keyFile)); - } else { - System.out.println("No .key was not found. Trying dev mode."); - return Optional.of(WUDLoader.loadDev(file.getAbsolutePath())); - } - } catch (Exception e) { - StringWriter errors = new StringWriter(); - e.printStackTrace(new PrintWriter(errors)); - System.err.println(errors); - } - - return Optional.empty(); - } - protected void parseContents(WUDInfo wudInfo) { List dps = new ArrayList<>(); @@ -75,9 +43,12 @@ public class WUDFuseContainer extends GroupFuseContainer { try { dps = WUDLoader.getPartitonsAsFSTDataProvider(wudInfo, Settings.devCommonKey); } catch (IOException | ParseException e1) { + e.printStackTrace(); + e1.printStackTrace(); System.out.println("Ignoring " + input.getAbsolutePath() + " :" + e1.getClass().getName() + " " + e1.getMessage()); } } catch (Exception e) { + e.printStackTrace(); System.out.println("Ignoring " + input.getAbsolutePath() + " :" + e.getClass().getName() + " " + e.getMessage()); } diff --git a/src/main/java/de/mas/wiiu/jnus/fuse_wiiu/utils/WUDUtils.java b/src/main/java/de/mas/wiiu/jnus/fuse_wiiu/utils/WUDUtils.java new file mode 100644 index 0000000..d69fbc5 --- /dev/null +++ b/src/main/java/de/mas/wiiu/jnus/fuse_wiiu/utils/WUDUtils.java @@ -0,0 +1,44 @@ +package de.mas.wiiu.jnus.fuse_wiiu.utils; + +import java.io.File; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Optional; + +import org.apache.commons.io.FilenameUtils; + +import de.mas.wiiu.jnus.WUDLoader; +import de.mas.wiiu.jnus.fuse_wiiu.Settings; +import de.mas.wiiu.jnus.implementations.wud.parser.WUDInfo; + +public class WUDUtils { + public static Optional loadWUDInfo(File file) { + String FSfilename = file.getName(); + String basename = FilenameUtils.getBaseName(FSfilename); + File keyFile = new File(file.getParent() + File.separator + basename + ".key"); + + if (!keyFile.exists() && Settings.disckeyPath != null) { + System.out.println(".key not found at " + keyFile.getAbsolutePath()); + keyFile = new File(Settings.disckeyPath.getAbsoluteFile() + File.separator + basename + ".key"); + if (!keyFile.exists()) { + System.out.println(".key not found at " + keyFile.getAbsolutePath()); + } + } + + try { + if (keyFile.exists()) { + return Optional.of(WUDLoader.load(file.getAbsolutePath(), keyFile)); + } else { + System.out.println("No .key was not found. Trying dev mode."); + return Optional.of(WUDLoader.loadDev(file.getAbsolutePath())); + } + } catch (Exception e) { + e.printStackTrace(); + StringWriter errors = new StringWriter(); + e.printStackTrace(new PrintWriter(errors)); + System.err.println(errors); + } + + return Optional.empty(); + } +}