Fix some paths for *nix users.

This commit is contained in:
Maschell 2018-12-16 13:19:26 +01:00
parent 8016b3edaf
commit fa3b0df7d2
5 changed files with 19 additions and 9 deletions

View File

@ -16,6 +16,7 @@
****************************************************************************/
package de.mas.wiiu.jnus;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@ -69,8 +70,10 @@ public class NUSTitle {
}
public FSTEntry getFSTEntryByFullPath(String givenFullPath) {
String fullPath = givenFullPath.replaceAll("/", "\\\\");
if (!fullPath.startsWith("\\")) fullPath = "\\" + fullPath;
String fullPath = givenFullPath.replace("/", File.separator);
if (!fullPath.startsWith(File.separator)) {
fullPath = File.separator + fullPath;
}
for (FSTEntry f : getAllFSTEntriesFlat()) {
if (f.getFullPath().equals(fullPath)) {
return f;
@ -86,7 +89,7 @@ public class NUSTitle {
List<FSTEntry> result = new ArrayList<>();
for (FSTEntry f : files) {
String match = f.getFullPath().replaceAll("\\\\", "/");
String match = f.getFullPath().replace(File.separator, "/");
Matcher m = p.matcher(match);
if (m.matches()) {
result.add(f);

View File

@ -51,7 +51,7 @@ public final class FSTService {
fstEntryToOffsetMap.put(0, rootEntry);
int lastlevel = level;
String path = "\\";
String path = File.separator;
FSTEntry last = null;
for (int i = 1; i < totalEntries; i++) {

View File

@ -90,7 +90,7 @@ public final class WoomyParser {
String entryName = entry.getName();
Matcher matcher = pattern.matcher(entryName);
if (matcher.matches()) {
String[] tokens = entryName.split("[\\\\|/]"); // We only want the filename!
String[] tokens = entryName.replace(File.separator, "\\").split("[\\\\|/]"); // We only want the filename!
String filename = tokens[tokens.length - 1];
result.put(filename.toLowerCase(Locale.ENGLISH), entry);
}

View File

@ -16,6 +16,8 @@
****************************************************************************/
package de.mas.wiiu.jnus.implementations.wud.parser;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@ -136,11 +138,11 @@ public final class WUDInfoParser {
for (val dirChilden : siFST.getRoot().getDirChildren()) {
// The SI partition contains the tmd, cert and tik for every GM partition.
byte[] rawTIK = getFSTEntryAsByte(dirChilden.getFullPath() + "\\" + WUD_TICKET_FILENAME, siPartition, siFST, wudInfo.getWUDDiscReader(),
byte[] rawTIK = getFSTEntryAsByte(dirChilden.getFullPath() + File.separator + WUD_TICKET_FILENAME, siPartition, siFST, wudInfo.getWUDDiscReader(),
wudInfo.getTitleKey());
byte[] rawTMD = getFSTEntryAsByte(dirChilden.getFullPath() + "\\" + WUD_TMD_FILENAME, siPartition, siFST, wudInfo.getWUDDiscReader(),
byte[] rawTMD = getFSTEntryAsByte(dirChilden.getFullPath() + File.separator + WUD_TMD_FILENAME, siPartition, siFST, wudInfo.getWUDDiscReader(),
wudInfo.getTitleKey());
byte[] rawCert = getFSTEntryAsByte(dirChilden.getFullPath() + "\\" + WUD_CERT_FILENAME, siPartition, siFST, wudInfo.getWUDDiscReader(),
byte[] rawCert = getFSTEntryAsByte(dirChilden.getFullPath() + File.separator + WUD_CERT_FILENAME, siPartition, siFST, wudInfo.getWUDDiscReader(),
wudInfo.getTitleKey());
String partitionName = "GM" + Utils.ByteArrayToString(Arrays.copyOfRange(rawTIK, 0x1DC, 0x1DC + 0x08));
@ -179,6 +181,11 @@ public final class WUDInfoParser {
private static byte[] getFSTEntryAsByte(String filePath, WUDPartition partition, FST fst, WUDDiscReader discReader, byte[] key) throws IOException {
FSTEntry entry = getEntryByFullPath(fst.getRoot(), filePath);
if(entry == null) {
String errormsg = "FSTEntry with name \"" + filePath + "\" not found.";
log.warning(errormsg);
throw new FileNotFoundException(errormsg);
}
ContentFSTInfo info = fst.getContentFSTInfos().get((int) entry.getContentFSTID());

View File

@ -236,7 +236,7 @@ public final class HashUtil {
if (!Arrays.equals(real_h0_hash, expected_h0_hash)) {
throw new CheckSumWrongException("h0 checksumfail", real_h0_hash, expected_h0_hash);
} else {
log.finest("h1 checksum right!");
log.finest("h0 checksum right!");
}
if ((block % 16) == 0) {