From 03f29b8f014488bb304db42dd468277ec74db835 Mon Sep 17 00:00:00 2001 From: Maschell Date: Mon, 3 Jun 2019 22:26:06 +0200 Subject: [PATCH] Initial support for .wumad files. --- pom.xml | 2 +- .../implementation/WUMADFuseContainer.java | 99 +++++++++++++++++++ .../fuse_wiiu/utils/FuseContainerWrapper.java | 7 ++ 3 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 src/main/java/de/mas/wiiu/jnus/fuse_wiiu/implementation/WUMADFuseContainer.java diff --git a/pom.xml b/pom.xml index ba05d9b..8fc6db9 100644 --- a/pom.xml +++ b/pom.xml @@ -92,7 +92,7 @@ com.github.Maschell JNUSLib - 95802c7 + cb0874d org.projectlombok diff --git a/src/main/java/de/mas/wiiu/jnus/fuse_wiiu/implementation/WUMADFuseContainer.java b/src/main/java/de/mas/wiiu/jnus/fuse_wiiu/implementation/WUMADFuseContainer.java new file mode 100644 index 0000000..dc00c40 --- /dev/null +++ b/src/main/java/de/mas/wiiu/jnus/fuse_wiiu/implementation/WUMADFuseContainer.java @@ -0,0 +1,99 @@ +package de.mas.wiiu.jnus.fuse_wiiu.implementation; + +import java.io.File; +import java.io.IOException; +import java.text.ParseException; +import java.util.Optional; + +import de.mas.wiiu.jnus.NUSTitle; +import de.mas.wiiu.jnus.NUSTitleLoaderFST; +import de.mas.wiiu.jnus.NUSTitleLoaderWumad; +import de.mas.wiiu.jnus.entities.fst.FSTEntry; +import de.mas.wiiu.jnus.fuse_wiiu.Settings; +import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseDirectory; +import de.mas.wiiu.jnus.implementations.FSTDataProviderNUSTitle; +import de.mas.wiiu.jnus.interfaces.FSTDataProvider; +import de.mas.wiiu.jnus.utils.FSTUtils; + +public class WUMADFuseContainer extends GroupFuseContainer { + private final File file; + + public WUMADFuseContainer(Optional parent, File c) { + super(parent); + this.file = c; + } + + @Override + protected void doInit() { + + FSTDataProvider dp; + try { + dp = new FSTDataProviderNUSTitle(getNUSTitle()); + + this.addFuseContainer("[EMULATED] [P01]", new FSTDataProviderContainer(Optional.of(this), () -> { + try { + return dp; + } catch (Exception e1) { + e1.printStackTrace(); + return null; + } + })); + + GroupFuseContainer children = new GroupFuseContainerDefault(Optional.of(this)); + this.addFuseContainer("[EMULATED] [P01] [EXTRA] ", children); + + for (FSTEntry tmd : FSTUtils.getFSTEntriesByRegEx(dp.getRoot(), ".*tmd")) { + Optional parentOpt = tmd.getParent(); + if (parentOpt.isPresent()) { + FSTEntry parent = parentOpt.get(); + if (parent.getFileChildren().stream().filter(f -> f.getFilename().endsWith(".app")).findAny().isPresent()) { + FSTDataProvider fdp = null; + try { + fdp = new FSTDataProviderNUSTitle(NUSTitleLoaderFST.loadNUSTitle(dp, parent, Settings.retailCommonKey)); + } catch (IOException | ParseException e) { + try { + fdp = new FSTDataProviderNUSTitle(NUSTitleLoaderFST.loadNUSTitle(dp, parent, Settings.devCommonKey)); + } catch (Exception e1) { + System.out.println("Ignoring " + parent.getFilename() + " :" + e1.getClass().getName() + " " + e1.getMessage()); + continue; + } + } catch (Exception e) { + System.out.println("Ignoring " + parent.getFilename() + " :" + e.getClass().getName() + " " + e.getMessage()); + continue; + } + + FSTDataProvider fdpCpy = fdp; + + children.addFuseContainer("[P01] [DECRYPTED] [" + dp.getName() + "] " + parent.getFilename(), + new FSTDataProviderContainer(getParent(), fdpCpy)); + } + } + } + + } catch (IOException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } catch (ParseException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + + } + + private NUSTitle getNUSTitle() throws IOException, ParseException { + NUSTitle t = null; + try { + try { + t = NUSTitleLoaderWumad.loadNUSTitle(file, Settings.retailCommonKey); + } catch (ParseException e) { + t = NUSTitleLoaderWumad.loadNUSTitle(file, Settings.devCommonKey); + } + } catch (Exception e) { + e.printStackTrace(); + System.out.println("Ignoring " + file.getAbsolutePath() + " :" + e.getClass().getName() + " " + e.getMessage()); + } + + return t; + } + +} diff --git a/src/main/java/de/mas/wiiu/jnus/fuse_wiiu/utils/FuseContainerWrapper.java b/src/main/java/de/mas/wiiu/jnus/fuse_wiiu/utils/FuseContainerWrapper.java index fdeb312..762130f 100644 --- a/src/main/java/de/mas/wiiu/jnus/fuse_wiiu/utils/FuseContainerWrapper.java +++ b/src/main/java/de/mas/wiiu/jnus/fuse_wiiu/utils/FuseContainerWrapper.java @@ -11,6 +11,7 @@ import de.mas.wiiu.jnus.fuse_wiiu.implementation.LocalNUSTitleContainer; import de.mas.wiiu.jnus.fuse_wiiu.implementation.WUDFuseContainer; import de.mas.wiiu.jnus.fuse_wiiu.implementation.WUDMountedFuseContainer; import de.mas.wiiu.jnus.fuse_wiiu.implementation.WUDToWUDContainer; +import de.mas.wiiu.jnus.fuse_wiiu.implementation.WUMADFuseContainer; import de.mas.wiiu.jnus.fuse_wiiu.implementation.WoomyNUSTitleContainer; import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseContainer; import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseDirectory; @@ -46,6 +47,12 @@ public class FuseContainerWrapper { result.put(prefix + c.getName(), new WoomyNUSTitleContainer(parent, c)); return result; } + + if (c.exists() && c.getName().endsWith(".wumad")) { + result.put(prefix + c.getName(), new WUMADFuseContainer(parent, c)); + return result; + } + if (checkWUD(result, parent, c)) { return result;