This actually does work if you don't try to load encrypted archives. Begin work to allow saving/loading in memory for tests. woo.
This commit is contained in:
11
src/main/java/net/runelite/cache/fs/Index.java
vendored
11
src/main/java/net/runelite/cache/fs/Index.java
vendored
@@ -35,6 +35,11 @@ public class Index implements Closeable
|
||||
index.close();
|
||||
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
public IndexFile getIndex()
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
public void load() throws IOException
|
||||
{
|
||||
@@ -243,7 +248,7 @@ public class Index implements Closeable
|
||||
assert this.index.getIndexFileId() == this.id;
|
||||
byte[] b = store.getData().read(this.id, entry.getId(), entry.getSector(), entry.getLength()); // needs decompress etc...
|
||||
|
||||
if (b == null) continue;
|
||||
//if (b == null) continue;
|
||||
|
||||
InputStream stream = new InputStream(b);
|
||||
|
||||
@@ -273,11 +278,11 @@ public class Index implements Closeable
|
||||
default:
|
||||
{
|
||||
int length = stream.readInt();
|
||||
if(length > 0 && length <= 1000000000) {
|
||||
// if(length > 0 && length <= 1000000000) {
|
||||
data = new byte[length];
|
||||
this.checkRevision(stream, compressedLength);
|
||||
GZipDecompressor.decompress(stream, data);
|
||||
} else continue;//data = null;
|
||||
// } else continue;//data = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
23
src/main/java/net/runelite/cache/fs/Store.java
vendored
23
src/main/java/net/runelite/cache/fs/Store.java
vendored
@@ -12,13 +12,15 @@ public class Store implements Closeable
|
||||
private static final String MAIN_FILE_CACHE_DAT = "main_file_cache.dat2";
|
||||
private static final String MAIN_FILE_CACHE_IDX = "main_file_cache.idx";
|
||||
|
||||
private final File folder;
|
||||
private final DataFile data;
|
||||
private final IndexFile index255;
|
||||
private final List<Index> indexes = new ArrayList<>();
|
||||
//private final List<IndexFile> indexFiles = new ArrayList<>();
|
||||
|
||||
public Store(File folder) throws IOException
|
||||
{
|
||||
this.folder = folder;
|
||||
|
||||
data = new DataFile(this, new File(folder, MAIN_FILE_CACHE_DAT));
|
||||
index255 = new IndexFile(this, 255, new File(folder, MAIN_FILE_CACHE_IDX + "255"));
|
||||
|
||||
@@ -29,7 +31,6 @@ public class Store implements Closeable
|
||||
|
||||
indexes.add(index);
|
||||
}
|
||||
//indexFiles.add(new IndexFile(this, i, new File(folder, MAIN_FILE_CACHE_IDX + i)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -42,10 +43,26 @@ public class Store implements Closeable
|
||||
i.close();
|
||||
}
|
||||
|
||||
public void addIndex(int id) throws FileNotFoundException
|
||||
{
|
||||
for (Index i : indexes)
|
||||
if (i.getIndex().getIndexFileId() == id)
|
||||
throw new IllegalArgumentException("index " + id + " already exists");
|
||||
|
||||
IndexFile indexFile = new IndexFile(this, id, new File(folder, MAIN_FILE_CACHE_IDX + id));
|
||||
Index index = new Index(this, indexFile, id);
|
||||
|
||||
this.indexes.add(index);
|
||||
}
|
||||
|
||||
public void load() throws IOException
|
||||
{
|
||||
for (Index i : indexes)
|
||||
i.load();
|
||||
{
|
||||
int id = i.getIndex().getIndexFileId();
|
||||
if (id == 3 || id == 7) // XXXXXXXXXXXXX
|
||||
i.load();
|
||||
}
|
||||
}
|
||||
|
||||
public DataFile getData()
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
@@ -12,6 +13,12 @@ public class DataFileTest
|
||||
{
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void before()
|
||||
{
|
||||
System.setProperty("java.io.tmpdir", "d:/temp");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1() throws IOException
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.runelite.cache.fs;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
@@ -12,6 +13,12 @@ public class IndexFileTest
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void before()
|
||||
{
|
||||
System.setProperty("java.io.tmpdir", "d:/temp");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1() throws IOException
|
||||
{
|
||||
|
||||
@@ -8,7 +8,8 @@ public class StoreLoadTest
|
||||
@Test
|
||||
public void test() throws IOException
|
||||
{
|
||||
Store store = new Store(new java.io.File("c:/rs/cache"));
|
||||
Store store = new Store(new java.io.File("d:/rs/07/cache"));//c:/rs/cache"));
|
||||
store.load();
|
||||
System.out.println(store);
|
||||
}
|
||||
}
|
||||
|
||||
25
src/test/java/net/runelite/cache/fs/StoreTest.java
vendored
Normal file
25
src/test/java/net/runelite/cache/fs/StoreTest.java
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
package net.runelite.cache.fs;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
public class StoreTest
|
||||
{
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void before()
|
||||
{
|
||||
System.setProperty("java.io.tmpdir", "d:/temp");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreate() throws IOException
|
||||
{
|
||||
Store store = new Store(folder.getRoot());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user