mirror of
https://github.com/Maschell/JNUSLib.git
synced 2024-11-22 07:59:19 +01:00
Force the use "/" as the path separator internally
This commit is contained in:
parent
c1a1961e03
commit
6981345467
@ -126,7 +126,7 @@ public class NUSTitle {
|
|||||||
.filter(e -> allowNotInPackage || !e.isNotInPackage()) //
|
.filter(e -> allowNotInPackage || !e.isNotInPackage()) //
|
||||||
.flatMap(e -> {
|
.flatMap(e -> {
|
||||||
if (!e.isDir()) {
|
if (!e.isDir()) {
|
||||||
if (p.matcher(e.getFullPath().replace("/", File.separator)).matches()) {
|
if (p.matcher(e.getFullPath()).matches()) {
|
||||||
return Stream.of(e);
|
return Stream.of(e);
|
||||||
} else {
|
} else {
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
|
@ -113,7 +113,7 @@ public class FSTEntry {
|
|||||||
private StringBuilder getPathInternal() {
|
private StringBuilder getPathInternal() {
|
||||||
if (parent.isPresent()) {
|
if (parent.isPresent()) {
|
||||||
FSTEntry par = parent.get();
|
FSTEntry par = parent.get();
|
||||||
return par.getPathInternal().append(par.getFilename()).append(File.separator);
|
return par.getPathInternal().append(par.getFilename()).append('/');
|
||||||
}
|
}
|
||||||
return new StringBuilder();
|
return new StringBuilder();
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ public final class WoomyParser {
|
|||||||
String entryName = entry.getName();
|
String entryName = entry.getName();
|
||||||
Matcher matcher = pattern.matcher(entryName);
|
Matcher matcher = pattern.matcher(entryName);
|
||||||
if (matcher.matches()) {
|
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];
|
String filename = tokens[tokens.length - 1];
|
||||||
result.put(filename.toLowerCase(Locale.ENGLISH), entry);
|
result.put(filename.toLowerCase(Locale.ENGLISH), entry);
|
||||||
}
|
}
|
||||||
|
@ -134,11 +134,11 @@ public final class WUDInfoParser {
|
|||||||
|
|
||||||
for (val dirChilden : siFST.getRoot().getDirChildren()) {
|
for (val dirChilden : siFST.getRoot().getDirChildren()) {
|
||||||
// The SI partition contains the tmd, cert and tik for every GM partition.
|
// 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());
|
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());
|
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());
|
wudInfo.getWUDDiscReader(), wudInfo.getTitleKey());
|
||||||
|
|
||||||
String partitionName = "GM" + Utils.ByteArrayToString(Arrays.copyOfRange(rawTIK, 0x1DC, 0x1DC + 0x08));
|
String partitionName = "GM" + Utils.ByteArrayToString(Arrays.copyOfRange(rawTIK, 0x1DC, 0x1DC + 0x08));
|
||||||
|
@ -30,14 +30,14 @@ import lombok.val;
|
|||||||
|
|
||||||
public class FSTUtils {
|
public class FSTUtils {
|
||||||
public static Optional<FSTEntry> getFSTEntryByFullPath(FSTEntry root, String givenFullPath) {
|
public static Optional<FSTEntry> getFSTEntryByFullPath(FSTEntry root, String givenFullPath) {
|
||||||
String fullPath = givenFullPath.replace("/", File.separator);
|
String fullPath = givenFullPath.replace(File.separator, "/");
|
||||||
if (!fullPath.startsWith(File.separator)) {
|
if (!fullPath.startsWith("/")) {
|
||||||
fullPath = File.separator + fullPath;
|
fullPath = "/" + fullPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
String dirPath = FilenameUtils.getFullPathNoEndSeparator(fullPath);
|
String dirPath = FilenameUtils.getFullPathNoEndSeparator(fullPath);
|
||||||
Optional<FSTEntry> pathOpt = Optional.of(root);
|
Optional<FSTEntry> pathOpt = Optional.of(root);
|
||||||
if (!dirPath.equals(File.separator)) {
|
if (!dirPath.equals("/")) {
|
||||||
pathOpt = getFileEntryDir(root, dirPath);
|
pathOpt = getFileEntryDir(root, dirPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,15 +47,16 @@ public class FSTUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<FSTEntry> getFileEntryDir(FSTEntry curEntry, String string) {
|
public static Optional<FSTEntry> getFileEntryDir(FSTEntry curEntry, String string) {
|
||||||
string = string.replace("/", File.separator);
|
string = string.replace(File.separator, "/");
|
||||||
|
|
||||||
if (!string.endsWith(File.separator)) {
|
// We add the "/" at the end so we don't get false results when using the "startWith" function.
|
||||||
string += File.separator;
|
if (!string.endsWith("/")) {
|
||||||
|
string += "/";
|
||||||
}
|
}
|
||||||
for (val curChild : curEntry.getDirChildren()) {
|
for (val curChild : curEntry.getDirChildren()) {
|
||||||
String compareTo = curChild.getFullPath();
|
String compareTo = curChild.getFullPath();
|
||||||
if (!compareTo.endsWith(File.separator)) {
|
if (!compareTo.endsWith("/")) {
|
||||||
compareTo += File.separator;
|
compareTo += "/";
|
||||||
}
|
}
|
||||||
if (string.startsWith(compareTo)) {
|
if (string.startsWith(compareTo)) {
|
||||||
if (string.equals(compareTo)) {
|
if (string.equals(compareTo)) {
|
||||||
@ -107,7 +108,7 @@ public class FSTUtils {
|
|||||||
.filter(e -> allowNotInPackage || !e.isNotInPackage()) //
|
.filter(e -> allowNotInPackage || !e.isNotInPackage()) //
|
||||||
.flatMap(e -> {
|
.flatMap(e -> {
|
||||||
if (!e.isDir()) {
|
if (!e.isDir()) {
|
||||||
if (p.matcher(e.getFullPath().replace("/", File.separator)).matches()) {
|
if (p.matcher(e.getFullPath()).matches()) {
|
||||||
return Stream.of(e);
|
return Stream.of(e);
|
||||||
} else {
|
} else {
|
||||||
return Stream.empty();
|
return Stream.empty();
|
||||||
|
Loading…
Reference in New Issue
Block a user