Formatting, optimize imports

This commit is contained in:
Maschell 2022-02-01 23:54:17 +01:00
parent 2793c02246
commit a3f9dcb648
22 changed files with 129 additions and 150 deletions

View File

@ -1,5 +1,13 @@
package de.mas.wiiu.jnus.fuse_wiiu;
import de.mas.wiiu.jnus.fuse_wiiu.implementation.GroupFuseContainer;
import de.mas.wiiu.jnus.fuse_wiiu.implementation.GroupFuseContainerDefault;
import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseContainer;
import de.mas.wiiu.jnus.fuse_wiiu.utils.FuseContainerWrapper;
import de.mas.wiiu.jnus.utils.HashUtil;
import de.mas.wiiu.jnus.utils.Utils;
import org.apache.commons.cli.*;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
@ -9,20 +17,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import de.mas.wiiu.jnus.fuse_wiiu.implementation.GroupFuseContainer;
import de.mas.wiiu.jnus.fuse_wiiu.implementation.GroupFuseContainerDefault;
import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseContainer;
import de.mas.wiiu.jnus.fuse_wiiu.utils.FuseContainerWrapper;
import de.mas.wiiu.jnus.utils.HashUtil;
import de.mas.wiiu.jnus.utils.Utils;
public class Main {
private static final String DEV_COMMON_KEY = "devcommon.key";
private static final String COMMON_KEY = "common.key";

View File

@ -1,13 +1,13 @@
package de.mas.wiiu.jnus.fuse_wiiu;
import java.io.File;
import de.mas.wiiu.jnus.utils.Utils;
import java.io.File;
public class Settings {
public static File disckeyPath = null;
public static final byte[] retailCommonKeyHash = Utils.StringToByteArray("6A0B87FC98B306AE3366F0E0A88D0B06A2813313");
public static final byte[] devCommonKeyHash = Utils.StringToByteArray("E191BFDB1232537D7DADEAD81F2A48FD6F188E02");
public static File disckeyPath = null;
public static File titlekeyPath = null;
public static byte[] retailCommonKey = new byte[16];
public static byte[] devCommonKey = new byte[16];

View File

@ -1,19 +1,14 @@
package de.mas.wiiu.jnus.fuse_wiiu.implementation;
import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.Timer;
import java.util.TimerTask;
import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseContainer;
import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseDirectory;
import de.mas.wiiu.jnus.fuse_wiiu.utils.FuseContainerWrapper;
import lombok.val;
import java.io.File;
import java.util.*;
import java.util.Map.Entry;
/**
* Representation of a directory on the OS filesystem. For every children of this directory the FuseContainerWrapper is used to create children if needed.
*

View File

@ -1,8 +1,5 @@
package de.mas.wiiu.jnus.fuse_wiiu.implementation;
import java.util.Optional;
import java.util.function.Supplier;
import de.mas.wiiu.jnus.entities.FST.nodeentry.DirectoryEntry;
import de.mas.wiiu.jnus.entities.FST.nodeentry.FileEntry;
import de.mas.wiiu.jnus.entities.FST.nodeentry.NodeEntry;
@ -17,6 +14,9 @@ import ru.serce.jnrfuse.FuseFillDir;
import ru.serce.jnrfuse.struct.FileStat;
import ru.serce.jnrfuse.struct.FuseFileInfo;
import java.util.Optional;
import java.util.function.Supplier;
/**
* FuseContainer implementation based on a FSTDataProvider.
*

View File

@ -1,12 +1,5 @@
package de.mas.wiiu.jnus.fuse_wiiu.implementation;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Map.Entry;
import java.util.function.BiFunction;
import java.util.stream.Collectors;
import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseContainer;
import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseDirectory;
import jnr.ffi.Pointer;
@ -17,11 +10,17 @@ import ru.serce.jnrfuse.FuseFillDir;
import ru.serce.jnrfuse.struct.FileStat;
import ru.serce.jnrfuse.struct.FuseFileInfo;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.stream.Collectors;
/**
* Implementation of an FuseContainer which can hold serveral FuseContainers emulated as directories.
*
* @author Maschell
*
*/
public abstract class GroupFuseContainer implements FuseContainer {
private final Map<String, FuseContainer> containerMap = new HashMap<>();

View File

@ -1,13 +1,13 @@
package de.mas.wiiu.jnus.fuse_wiiu.implementation;
import java.util.Optional;
import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseDirectory;
import java.util.Optional;
/**
* Default GroupFuseContainer implementation
* @author Maschell
*
* @author Maschell
*/
public class GroupFuseContainerDefault extends GroupFuseContainer {

View File

@ -1,9 +1,5 @@
package de.mas.wiiu.jnus.fuse_wiiu.implementation;
import java.io.File;
import java.io.IOException;
import java.util.Optional;
import de.mas.wiiu.jnus.NUSTitle;
import de.mas.wiiu.jnus.NUSTitleLoaderLocalBackup;
import de.mas.wiiu.jnus.entities.Ticket;
@ -13,6 +9,10 @@ import de.mas.wiiu.jnus.fuse_wiiu.utils.TicketUtils;
import de.mas.wiiu.jnus.implementations.FSTDataProviderNUSTitle;
import de.mas.wiiu.jnus.utils.Utils;
import java.io.File;
import java.io.IOException;
import java.util.Optional;
public class LocalBackupNUSTitleContainer extends GroupFuseContainer {
private File folder;

View File

@ -1,19 +1,19 @@
package de.mas.wiiu.jnus.fuse_wiiu.implementation;
import de.mas.wiiu.jnus.NUSTitle;
import de.mas.wiiu.jnus.NUSTitleLoaderLocal;
import de.mas.wiiu.jnus.entities.TMD.TitleMetaData;
import de.mas.wiiu.jnus.entities.Ticket;
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.TicketUtils;
import de.mas.wiiu.jnus.implementations.FSTDataProviderNUSTitle;
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.NUSTitleLoaderLocal;
import de.mas.wiiu.jnus.entities.Ticket;
import de.mas.wiiu.jnus.entities.TMD.TitleMetaData;
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.TicketUtils;
import de.mas.wiiu.jnus.implementations.FSTDataProviderNUSTitle;
public class LocalNUSTitleContainer extends GroupFuseContainer {
private File folder;

View File

@ -1,14 +1,14 @@
package de.mas.wiiu.jnus.fuse_wiiu.implementation;
import java.io.File;
import java.util.List;
import java.util.Optional;
import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FSTDataProviderLoader;
import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseDirectory;
import de.mas.wiiu.jnus.interfaces.FSTDataProvider;
import lombok.val;
import java.io.File;
import java.util.List;
import java.util.Optional;
public class MultipleFSTDataProviderFuseContainer<T> extends GroupFuseContainer {
private final File file;
private final FSTDataProviderLoader<T> loader;

View File

@ -1,11 +1,5 @@
package de.mas.wiiu.jnus.fuse_wiiu.implementation;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.util.List;
import java.util.Optional;
import de.mas.wiiu.jnus.NUSTitleLoaderFST;
import de.mas.wiiu.jnus.entities.FST.nodeentry.DirectoryEntry;
import de.mas.wiiu.jnus.entities.FST.nodeentry.FileEntry;
@ -17,6 +11,12 @@ import de.mas.wiiu.jnus.interfaces.FSTDataProvider;
import de.mas.wiiu.jnus.interfaces.HasNUSTitle;
import de.mas.wiiu.jnus.utils.FSTUtils;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.util.List;
import java.util.Optional;
public class MultipleFSTDataProviderRecursiveFuseContainer<T> extends MultipleFSTDataProviderFuseContainer<T> {
public MultipleFSTDataProviderRecursiveFuseContainer(Optional<FuseDirectory> parent, File input, FSTDataProviderLoader<T> loader) {
super(parent, input, loader);

View File

@ -1,11 +1,5 @@
package de.mas.wiiu.jnus.fuse_wiiu.implementation;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.function.Supplier;
import de.mas.wiiu.jnus.NUSTitle;
import de.mas.wiiu.jnus.entities.TMD.Content;
import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseContainer;
@ -16,6 +10,12 @@ import ru.serce.jnrfuse.FuseFillDir;
import ru.serce.jnrfuse.struct.FileStat;
import ru.serce.jnrfuse.struct.FuseFileInfo;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.function.Supplier;
public class NUSTitleEncryptedFuseContainer implements FuseContainer {
private final Optional<FuseDirectory> parent;
private final NUSTitle title;

View File

@ -1,9 +1,5 @@
package de.mas.wiiu.jnus.fuse_wiiu.implementation;
import java.io.File;
import java.io.IOException;
import java.util.Optional;
import de.mas.wiiu.jnus.NUSTitle;
import de.mas.wiiu.jnus.NUSTitleLoaderRemoteLocal;
import de.mas.wiiu.jnus.entities.Ticket;
@ -13,6 +9,10 @@ import de.mas.wiiu.jnus.fuse_wiiu.utils.TicketUtils;
import de.mas.wiiu.jnus.implementations.FSTDataProviderNUSTitle;
import de.mas.wiiu.jnus.utils.Utils;
import java.io.File;
import java.io.IOException;
import java.util.Optional;
public class RemoteLocalBackupNUSTitleContainer extends GroupFuseContainer {
private File folder;

View File

@ -1,9 +1,5 @@
package de.mas.wiiu.jnus.fuse_wiiu.implementation;
import java.io.File;
import java.io.IOException;
import java.util.Optional;
import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseContainer;
import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseDirectory;
import de.mas.wiiu.jnus.fuse_wiiu.utils.WUDUtils;
@ -15,6 +11,10 @@ import ru.serce.jnrfuse.FuseFillDir;
import ru.serce.jnrfuse.struct.FileStat;
import ru.serce.jnrfuse.struct.FuseFileInfo;
import java.io.File;
import java.io.IOException;
import java.util.Optional;
public class WUDToWUDContainer implements FuseContainer {
private final String filename;
private final Optional<WiiUDisc> wudInfo;

View File

@ -1,12 +1,12 @@
package de.mas.wiiu.jnus.fuse_wiiu.implementation;
import java.io.File;
import java.util.Optional;
import de.mas.wiiu.jnus.NUSTitleLoaderWoomy;
import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseDirectory;
import de.mas.wiiu.jnus.implementations.FSTDataProviderNUSTitle;
import java.io.File;
import java.util.Optional;
public class WoomyNUSTitleContainer extends GroupFuseContainer {
private final File file;

View File

@ -1,12 +1,5 @@
package de.mas.wiiu.jnus.fuse_wiiu.implementation.loader;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import de.mas.wiiu.jnus.WUDLoader;
import de.mas.wiiu.jnus.fuse_wiiu.Settings;
import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FSTDataProviderLoader;
@ -15,9 +8,16 @@ import de.mas.wiiu.jnus.implementations.wud.WiiUDisc;
import de.mas.wiiu.jnus.interfaces.FSTDataProvider;
import lombok.Getter;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
public class WUDFSTDataProviderLoader implements FSTDataProviderLoader<WiiUDisc> {
@Getter
private static WUDFSTDataProviderLoader instance = new WUDFSTDataProviderLoader();
private static final WUDFSTDataProviderLoader instance = new WUDFSTDataProviderLoader();
private WUDFSTDataProviderLoader() {
}

View File

@ -1,12 +1,5 @@
package de.mas.wiiu.jnus.fuse_wiiu.implementation.loader;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import de.mas.wiiu.jnus.WumadLoader;
import de.mas.wiiu.jnus.fuse_wiiu.Settings;
import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FSTDataProviderLoader;
@ -14,9 +7,16 @@ import de.mas.wiiu.jnus.implementations.wud.wumad.WumadInfo;
import de.mas.wiiu.jnus.interfaces.FSTDataProvider;
import lombok.Getter;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
public class WumadFSTDataProviderLoader implements FSTDataProviderLoader<WumadInfo> {
@Getter
private static WumadFSTDataProviderLoader instance = new WumadFSTDataProviderLoader();
private static final WumadFSTDataProviderLoader instance = new WumadFSTDataProviderLoader();
private WumadFSTDataProviderLoader() {
}

View File

@ -1,13 +1,13 @@
package de.mas.wiiu.jnus.fuse_wiiu.interfaces;
import de.mas.wiiu.jnus.interfaces.FSTDataProvider;
import java.io.File;
import java.util.List;
import java.util.Optional;
import de.mas.wiiu.jnus.interfaces.FSTDataProvider;
public interface FSTDataProviderLoader<T> {
public Optional<T> loadInfo(File input);
Optional<T> loadInfo(File input);
public List<FSTDataProvider> getDataProvider(T info);
List<FSTDataProvider> getDataProvider(T info);
}

View File

@ -11,24 +11,24 @@ import ru.serce.jnrfuse.struct.FuseFileInfo;
* Simplified version of the FuseFS interface.
*
* @author Maschell
*
*/
public interface FuseContainer extends FuseDirectory {
/**
* Wrapper for the getattr function of the FuseFS interface.
* When this function is called, the path will be relative to this FuseContainer
*
* <p>
* Get file attributes.
* <p>
* Similar to stat(). The 'st_dev' and 'st_blksize' fields are
* ignored. The 'st_ino' field is ignored except if the 'use_ino'
* mount option is given.
*/
public int getattr(String path, FileStat stat);
int getattr(String path, FileStat stat);
/**
* Wrapper for the getattr function of the FuseFS interface.
* When this function is called, the path will be relative to this FuseContainer
*
* <p>
* File open operation
* <p>
* No creation (O_CREAT, O_EXCL) and by default also no
@ -46,12 +46,12 @@ public interface FuseContainer extends FuseDirectory {
*
* @see jnr.constants.platform.OpenFlags
*/
public int open(String path, FuseFileInfo fi);
int open(String path, FuseFileInfo fi);
/**
* Wrapper for the readdir function of the FuseFS interface.
* When this function is called, the path will be relative to this FuseContainer
*
* <p>
* Read directory
* <p>
* This supersedes the old getdir() interface. New applications
@ -71,12 +71,12 @@ public interface FuseContainer extends FuseDirectory {
* is full (or an error happens) the filler function will return
* '1'.
*/
public int readdir(String path, Pointer buf, FuseFillDir filter, @off_t long offset, FuseFileInfo fi);
int readdir(String path, Pointer buf, FuseFillDir filter, @off_t long offset, FuseFileInfo fi);
/**
* Wrapper for the getattr function of the FuseFS interface.
* When this function is called, the path will be relative to this FuseContainer
*
* <p>
* Read data from an open file
* <p>
* Read should return exactly the number of bytes requested except
@ -86,17 +86,17 @@ public interface FuseContainer extends FuseDirectory {
* value of the read system call will reflect the return value of
* this operation.
*/
public int read(String path, Pointer buf, @size_t long size, @off_t long offset, FuseFileInfo fi);
int read(String path, Pointer buf, @size_t long size, @off_t long offset, FuseFileInfo fi);
/**
* This function will be called when ever the FuseContainer needs to update it's children.
*/
public void init();
void init();
/**
* This function will be called right before this FuseContainer won't be used anymore.
*/
public void deinit();
void deinit();
}

View File

@ -6,7 +6,6 @@ import java.util.Optional;
* Representation of a directory.
*
* @author Maschell
*
*/
public interface FuseDirectory {
@ -15,5 +14,5 @@ public interface FuseDirectory {
*
* @return parent
*/
public Optional<FuseDirectory> getParent();
Optional<FuseDirectory> getParent();
}

View File

@ -1,18 +1,6 @@
package de.mas.wiiu.jnus.fuse_wiiu.utils;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import de.mas.wiiu.jnus.fuse_wiiu.implementation.FSFuseContainer;
import de.mas.wiiu.jnus.fuse_wiiu.implementation.LocalBackupNUSTitleContainer;
import de.mas.wiiu.jnus.fuse_wiiu.implementation.LocalNUSTitleContainer;
import de.mas.wiiu.jnus.fuse_wiiu.implementation.MultipleFSTDataProviderFuseContainer;
import de.mas.wiiu.jnus.fuse_wiiu.implementation.MultipleFSTDataProviderRecursiveFuseContainer;
import de.mas.wiiu.jnus.fuse_wiiu.implementation.RemoteLocalBackupNUSTitleContainer;
import de.mas.wiiu.jnus.fuse_wiiu.implementation.WUDToWUDContainer;
import de.mas.wiiu.jnus.fuse_wiiu.implementation.WoomyNUSTitleContainer;
import de.mas.wiiu.jnus.fuse_wiiu.implementation.*;
import de.mas.wiiu.jnus.fuse_wiiu.implementation.loader.WUDFSTDataProviderLoader;
import de.mas.wiiu.jnus.fuse_wiiu.implementation.loader.WumadFSTDataProviderLoader;
import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseContainer;
@ -20,6 +8,11 @@ import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseDirectory;
import de.mas.wiiu.jnus.implementations.wud.reader.WUDDiscReaderSplitted;
import de.mas.wiiu.jnus.utils.Utils;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
public class FuseContainerWrapper {
private final static String prefix = "[EMULATED] ";

View File

@ -1,13 +1,13 @@
package de.mas.wiiu.jnus.fuse_wiiu.utils;
import de.mas.wiiu.jnus.entities.Ticket;
import de.mas.wiiu.jnus.utils.FileUtils;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Optional;
import de.mas.wiiu.jnus.entities.Ticket;
import de.mas.wiiu.jnus.utils.FileUtils;
public class TicketUtils {
public static Optional<Ticket> getTicket(File folder, File keyFolder, long titleID, byte[] commonKey) {
File ticketFile = null;

View File

@ -1,16 +1,15 @@
package de.mas.wiiu.jnus.fuse_wiiu.utils;
import de.mas.wiiu.jnus.WUDLoader;
import de.mas.wiiu.jnus.fuse_wiiu.Settings;
import de.mas.wiiu.jnus.implementations.wud.WiiUDisc;
import org.apache.commons.io.FilenameUtils;
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.WiiUDisc;
public class WUDUtils {
public static Optional<WiiUDisc> loadWUDInfo(File file) {
String FSfilename = file.getName();