Well this doesnt work at all
This commit is contained in:
55
src/main/java/net/runelite/cache/fs/Index.java
vendored
55
src/main/java/net/runelite/cache/fs/Index.java
vendored
@@ -44,7 +44,7 @@ public class Index implements Closeable
|
|||||||
IndexFile index255 = store.getIndex255();
|
IndexFile index255 = store.getIndex255();
|
||||||
|
|
||||||
IndexEntry entry = index255.read(id);
|
IndexEntry entry = index255.read(id);
|
||||||
byte[] b = dataFile.read(id, entry.getId(), entry.getSector(), entry.getLength());
|
byte[] b = dataFile.read(index255.getIndexFileId(), entry.getId(), entry.getSector(), entry.getLength());
|
||||||
|
|
||||||
InputStream stream = new InputStream(b);
|
InputStream stream = new InputStream(b);
|
||||||
|
|
||||||
@@ -239,12 +239,53 @@ public class Index implements Closeable
|
|||||||
for (Archive a : archives)
|
for (Archive a : archives)
|
||||||
{
|
{
|
||||||
IndexEntry entry = this.index.read(a.getArchiveId());
|
IndexEntry entry = this.index.read(a.getArchiveId());
|
||||||
byte[] data = store.getData().read(this.id, entry.getId(), entry.getSector(), entry.getLength());
|
//is this id supposed to be this.index.id? are those the same?
|
||||||
|
assert this.index.getIndexFileId() == this.id;
|
||||||
|
byte[] b = store.getData().read(this.id, entry.getId(), entry.getSector(), entry.getLength()); // needs decompress etc...
|
||||||
|
|
||||||
// if (a.getFiles().size() == 1)
|
if (b == null) continue;
|
||||||
// {
|
|
||||||
// //
|
InputStream stream = new InputStream(b);
|
||||||
// }
|
|
||||||
|
this.compression = stream.readUnsignedByte();
|
||||||
|
int compressedLength = stream.readInt();
|
||||||
|
if (compressedLength < 0 || compressedLength > 1000000)
|
||||||
|
{
|
||||||
|
throw new RuntimeException("Invalid archive header");
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] data;
|
||||||
|
switch (compression)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
data = new byte[compressedLength];
|
||||||
|
this.checkRevision(stream, compressedLength);
|
||||||
|
stream.readBytes(data, 0, compressedLength);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
int length = stream.readInt();
|
||||||
|
data = new byte[length];
|
||||||
|
this.checkRevision(stream, compressedLength);
|
||||||
|
BZip2Decompressor.decompress(data, b, compressedLength, 9);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
int length = stream.readInt();
|
||||||
|
if(length > 0 && length <= 1000000000) {
|
||||||
|
data = new byte[length];
|
||||||
|
this.checkRevision(stream, compressedLength);
|
||||||
|
GZipDecompressor.decompress(stream, data);
|
||||||
|
} else continue;//data = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a.getFiles().size() == 1)
|
||||||
|
{
|
||||||
|
a.getFiles().get(0).setContents(data);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
final int filesCount = a.getFiles().size();
|
final int filesCount = a.getFiles().size();
|
||||||
|
|
||||||
@@ -252,7 +293,7 @@ public class Index implements Closeable
|
|||||||
--readPosition;
|
--readPosition;
|
||||||
int amtOfLoops = data[readPosition] & 255;
|
int amtOfLoops = data[readPosition] & 255;
|
||||||
readPosition -= amtOfLoops * filesCount * 4;
|
readPosition -= amtOfLoops * filesCount * 4;
|
||||||
InputStream stream = new InputStream(data);
|
stream = new InputStream(data);
|
||||||
stream.setOffset(readPosition);
|
stream.setOffset(readPosition);
|
||||||
int[] filesSize = new int[filesCount];
|
int[] filesSize = new int[filesCount];
|
||||||
|
|
||||||
|
|||||||
14
src/test/java/net/runelite/cache/fs/StoreLoadTest.java
vendored
Normal file
14
src/test/java/net/runelite/cache/fs/StoreLoadTest.java
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package net.runelite.cache.fs;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class StoreLoadTest
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void test() throws IOException
|
||||||
|
{
|
||||||
|
Store store = new Store(new java.io.File("c:/rs/cache"));
|
||||||
|
store.load();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user