mirror of
https://github.com/Maschell/JNUSLib.git
synced 2024-11-22 07:59:19 +01:00
Throw a ParseException on error in the FST and FSTService
This commit is contained in:
parent
d1fb43bf65
commit
cf6b52780c
@ -16,6 +16,7 @@
|
||||
****************************************************************************/
|
||||
package de.mas.wiiu.jnus.entities.fst;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -52,12 +53,11 @@ public final class FST {
|
||||
* @param contentsMappedByIndex
|
||||
* map of index/content
|
||||
* @return
|
||||
* @throws ParseException
|
||||
*/
|
||||
public static FST parseFST(byte[] fstData, Map<Integer, Content> contentsMappedByIndex) {
|
||||
public static FST parseFST(byte[] fstData, Map<Integer, Content> contentsMappedByIndex) throws ParseException {
|
||||
if (!Arrays.equals(Arrays.copyOfRange(fstData, 0, 3), new byte[] { 0x46, 0x53, 0x54 })) {
|
||||
throw new RuntimeException("Failed to parse FST");
|
||||
// return null;
|
||||
// throw new IllegalArgumentException("Not a FST. Maybe a wrong key?");
|
||||
throw new ParseException("Failed to parse FST",0);
|
||||
}
|
||||
|
||||
int sectorSize = ByteUtils.getIntFromBytes(fstData, 0x04);
|
||||
|
@ -16,6 +16,7 @@
|
||||
****************************************************************************/
|
||||
package de.mas.wiiu.jnus.entities.fst;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -33,7 +34,7 @@ public final class FSTService {
|
||||
}
|
||||
|
||||
public static void parseFST(FSTEntry rootEntry, byte[] fstSection, byte[] namesSection, Map<Integer, Content> contentsByIndex,
|
||||
Map<Integer, ContentFSTInfo> contentsFSTByIndex, int sectorSize) {
|
||||
Map<Integer, ContentFSTInfo> contentsFSTByIndex, int sectorSize) throws ParseException {
|
||||
int totalEntries = ByteUtils.getIntFromBytes(fstSection, 0x08);
|
||||
|
||||
int level = 0;
|
||||
@ -103,12 +104,14 @@ public final class FSTService {
|
||||
Content content = contentsByIndex.get((int) contentIndex);
|
||||
if (content == null) {
|
||||
log.warning("Content for FST Entry not found");
|
||||
throw new ParseException("Content for FST Entry not found", 0);
|
||||
} else {
|
||||
entryParam.setContent(content);
|
||||
|
||||
ContentFSTInfo contentFSTInfo = contentsFSTByIndex.get((int) contentIndex);
|
||||
if (contentFSTInfo == null) {
|
||||
log.warning("ContentFSTInfo for FST Entry not found");
|
||||
throw new ParseException("ContentFSTInfo for FST Entry not found", 0);
|
||||
} else {
|
||||
content.setContentFSTInfo(contentFSTInfo);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user