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