Force the use "/" as the path separator internally

This commit is contained in:
Maschell 2019-04-24 13:53:07 +02:00
parent c1a1961e03
commit 6981345467
5 changed files with 18 additions and 17 deletions

View File

@ -126,7 +126,7 @@ public class NUSTitle {
.filter(e -> allowNotInPackage || !e.isNotInPackage()) //
.flatMap(e -> {
if (!e.isDir()) {
if (p.matcher(e.getFullPath().replace("/", File.separator)).matches()) {
if (p.matcher(e.getFullPath()).matches()) {
return Stream.of(e);
} else {
return Stream.empty();

View File

@ -113,7 +113,7 @@ public class FSTEntry {
private StringBuilder getPathInternal() {
if (parent.isPresent()) {
FSTEntry par = parent.get();
return par.getPathInternal().append(par.getFilename()).append(File.separator);
return par.getPathInternal().append(par.getFilename()).append('/');
}
return new StringBuilder();
}

View File

@ -93,7 +93,7 @@ public final class WoomyParser {
String entryName = entry.getName();
Matcher matcher = pattern.matcher(entryName);
if (matcher.matches()) {
String[] tokens = entryName.replace(File.separator, "\\").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

@ -134,11 +134,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() + File.separator + WUD_TICKET_FILENAME, siPartitionOffset, headerSize, siFST,
byte[] rawTIK = getFSTEntryAsByte(dirChilden.getFullPath() + '/' + WUD_TICKET_FILENAME, siPartitionOffset, headerSize, siFST,
wudInfo.getWUDDiscReader(), wudInfo.getTitleKey());
byte[] rawTMD = getFSTEntryAsByte(dirChilden.getFullPath() + File.separator + WUD_TMD_FILENAME, siPartitionOffset, headerSize, siFST,
byte[] rawTMD = getFSTEntryAsByte(dirChilden.getFullPath() + '/' + WUD_TMD_FILENAME, siPartitionOffset, headerSize, siFST,
wudInfo.getWUDDiscReader(), wudInfo.getTitleKey());
byte[] rawCert = getFSTEntryAsByte(dirChilden.getFullPath() + File.separator + WUD_CERT_FILENAME, siPartitionOffset, headerSize, siFST,
byte[] rawCert = getFSTEntryAsByte(dirChilden.getFullPath() + '/' + WUD_CERT_FILENAME, siPartitionOffset, headerSize, siFST,
wudInfo.getWUDDiscReader(), wudInfo.getTitleKey());
String partitionName = "GM" + Utils.ByteArrayToString(Arrays.copyOfRange(rawTIK, 0x1DC, 0x1DC + 0x08));

View File

@ -30,14 +30,14 @@ import lombok.val;
public class FSTUtils {
public static Optional<FSTEntry> getFSTEntryByFullPath(FSTEntry root, String givenFullPath) {
String fullPath = givenFullPath.replace("/", File.separator);
if (!fullPath.startsWith(File.separator)) {
fullPath = File.separator + fullPath;
String fullPath = givenFullPath.replace(File.separator, "/");
if (!fullPath.startsWith("/")) {
fullPath = "/" + fullPath;
}
String dirPath = FilenameUtils.getFullPathNoEndSeparator(fullPath);
Optional<FSTEntry> pathOpt = Optional.of(root);
if (!dirPath.equals(File.separator)) {
if (!dirPath.equals("/")) {
pathOpt = getFileEntryDir(root, dirPath);
}
@ -47,15 +47,16 @@ public class FSTUtils {
}
public static Optional<FSTEntry> getFileEntryDir(FSTEntry curEntry, String string) {
string = string.replace("/", File.separator);
string = string.replace(File.separator, "/");
if (!string.endsWith(File.separator)) {
string += File.separator;
// We add the "/" at the end so we don't get false results when using the "startWith" function.
if (!string.endsWith("/")) {
string += "/";
}
for (val curChild : curEntry.getDirChildren()) {
String compareTo = curChild.getFullPath();
if (!compareTo.endsWith(File.separator)) {
compareTo += File.separator;
if (!compareTo.endsWith("/")) {
compareTo += "/";
}
if (string.startsWith(compareTo)) {
if (string.equals(compareTo)) {
@ -107,7 +108,7 @@ public class FSTUtils {
.filter(e -> allowNotInPackage || !e.isNotInPackage()) //
.flatMap(e -> {
if (!e.isDir()) {
if (p.matcher(e.getFullPath().replace("/", File.separator)).matches()) {
if (p.matcher(e.getFullPath()).matches()) {
return Stream.of(e);
} else {
return Stream.empty();