mirror of
https://github.com/revanced/ARSCLib.git
synced 2025-05-09 10:14:25 +02:00
create string pool reader
This commit is contained in:
parent
e3097de134
commit
459307ac26
@ -17,10 +17,16 @@ package com.reandroid.lib.arsc.pool;
|
||||
|
||||
import com.reandroid.lib.arsc.array.StringArray;
|
||||
import com.reandroid.lib.arsc.array.TableStringArray;
|
||||
import com.reandroid.lib.arsc.chunk.ChunkType;
|
||||
import com.reandroid.lib.arsc.header.HeaderBlock;
|
||||
import com.reandroid.lib.arsc.io.BlockReader;
|
||||
import com.reandroid.lib.arsc.item.IntegerArray;
|
||||
import com.reandroid.lib.arsc.item.IntegerItem;
|
||||
import com.reandroid.lib.arsc.item.TableString;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class TableStringPool extends BaseStringPool<TableString> {
|
||||
public TableStringPool(boolean is_utf8) {
|
||||
super(is_utf8);
|
||||
@ -49,4 +55,22 @@ public class TableStringPool extends BaseStringPool<TableString> {
|
||||
getStyleArray().merge(stringPool.getStyleArray());
|
||||
refreshUniqueIdMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads string pool from table block (resources.arsc)
|
||||
*/
|
||||
public static TableStringPool readFromTable(InputStream inputStream) throws IOException {
|
||||
//TODO: for better result, make blockReader to
|
||||
// load buffer only the size of string pool
|
||||
BlockReader blockReader = new BlockReader(inputStream);
|
||||
HeaderBlock tableHeader = blockReader.readHeaderBlock();
|
||||
if(tableHeader.getChunkType()!=ChunkType.TABLE){
|
||||
throw new IOException("Not TableBlock: "+tableHeader);
|
||||
}
|
||||
blockReader.seek(tableHeader.getHeaderSize());
|
||||
TableStringPool stringPool = new TableStringPool(true);
|
||||
stringPool.readBytes(blockReader);
|
||||
blockReader.close();
|
||||
return stringPool;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user