[NUSTitle] Added functions getAllFSTEntriesAsStream and getAllFSTEntryChildrenAsStream

This commit is contained in:
Maschell 2019-02-28 21:34:41 +01:00
parent 9b179f51a6
commit 43d9d6f5cc

View File

@ -26,6 +26,7 @@ import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import de.mas.wiiu.jnus.entities.TMD;
import de.mas.wiiu.jnus.entities.Ticket;
@ -66,6 +67,25 @@ public class NUSTitle {
return getFSTEntriesFlatByContents(new ArrayList<Content>(getTMD().getAllContents().values()));
}
public Stream<FSTEntry> getAllFSTEntriesAsStream() {
return getAllFSTEntryChildrenAsStream(FST.getRoot());
}
public Stream<FSTEntry> getAllFSTEntryChildrenAsStream(FSTEntry cur) {
return getAllFSTEntryChildrenAsStream(cur, false);
}
public Stream<FSTEntry> getAllFSTEntryChildrenAsStream(FSTEntry cur, boolean allowNotInPackage) {
return cur.getChildren().stream() //
.filter(e -> allowNotInPackage || !e.isNotInPackage()) //
.flatMap(e -> {
if (!e.isDir()) {
return Stream.empty();
}
return getAllFSTEntryChildrenAsStream(e, allowNotInPackage);
});
}
public FSTEntry getFSTEntryByFullPath(String givenFullPath) {
String fullPath = givenFullPath.replace("/", File.separator);
if (!fullPath.startsWith(File.separator)) {