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
@@ -36,6 +36,11 @@ public class Index implements Closeable
|
|||||||
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
// 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
|
public void load() throws IOException
|
||||||
{
|
{
|
||||||
// read data from index255
|
// read data from index255
|
||||||
@@ -243,7 +248,7 @@ public class Index implements Closeable
|
|||||||
assert this.index.getIndexFileId() == this.id;
|
assert this.index.getIndexFileId() == this.id;
|
||||||
byte[] b = store.getData().read(this.id, entry.getId(), entry.getSector(), entry.getLength()); // needs decompress etc...
|
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);
|
InputStream stream = new InputStream(b);
|
||||||
|
|
||||||
@@ -273,11 +278,11 @@ public class Index implements Closeable
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
int length = stream.readInt();
|
int length = stream.readInt();
|
||||||
if(length > 0 && length <= 1000000000) {
|
// if(length > 0 && length <= 1000000000) {
|
||||||
data = new byte[length];
|
data = new byte[length];
|
||||||
this.checkRevision(stream, compressedLength);
|
this.checkRevision(stream, compressedLength);
|
||||||
GZipDecompressor.decompress(stream, data);
|
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_DAT = "main_file_cache.dat2";
|
||||||
private static final String MAIN_FILE_CACHE_IDX = "main_file_cache.idx";
|
private static final String MAIN_FILE_CACHE_IDX = "main_file_cache.idx";
|
||||||
|
|
||||||
|
private final File folder;
|
||||||
private final DataFile data;
|
private final DataFile data;
|
||||||
private final IndexFile index255;
|
private final IndexFile index255;
|
||||||
private final List<Index> indexes = new ArrayList<>();
|
private final List<Index> indexes = new ArrayList<>();
|
||||||
//private final List<IndexFile> indexFiles = new ArrayList<>();
|
|
||||||
|
|
||||||
public Store(File folder) throws IOException
|
public Store(File folder) throws IOException
|
||||||
{
|
{
|
||||||
|
this.folder = folder;
|
||||||
|
|
||||||
data = new DataFile(this, new File(folder, MAIN_FILE_CACHE_DAT));
|
data = new DataFile(this, new File(folder, MAIN_FILE_CACHE_DAT));
|
||||||
index255 = new IndexFile(this, 255, new File(folder, MAIN_FILE_CACHE_IDX + "255"));
|
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);
|
indexes.add(index);
|
||||||
}
|
}
|
||||||
//indexFiles.add(new IndexFile(this, i, new File(folder, MAIN_FILE_CACHE_IDX + i)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -42,10 +43,26 @@ public class Store implements Closeable
|
|||||||
i.close();
|
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
|
public void load() throws IOException
|
||||||
{
|
{
|
||||||
for (Index i : indexes)
|
for (Index i : indexes)
|
||||||
i.load();
|
{
|
||||||
|
int id = i.getIndex().getIndexFileId();
|
||||||
|
if (id == 3 || id == 7) // XXXXXXXXXXXXX
|
||||||
|
i.load();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataFile getData()
|
public DataFile getData()
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
@@ -13,6 +14,12 @@ public class DataFileTest
|
|||||||
@Rule
|
@Rule
|
||||||
public TemporaryFolder folder = new TemporaryFolder();
|
public TemporaryFolder folder = new TemporaryFolder();
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void before()
|
||||||
|
{
|
||||||
|
System.setProperty("java.io.tmpdir", "d:/temp");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test1() throws IOException
|
public void test1() throws IOException
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package net.runelite.cache.fs;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
@@ -12,6 +13,12 @@ public class IndexFileTest
|
|||||||
@Rule
|
@Rule
|
||||||
public TemporaryFolder folder = new TemporaryFolder();
|
public TemporaryFolder folder = new TemporaryFolder();
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void before()
|
||||||
|
{
|
||||||
|
System.setProperty("java.io.tmpdir", "d:/temp");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test1() throws IOException
|
public void test1() throws IOException
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ public class StoreLoadTest
|
|||||||
@Test
|
@Test
|
||||||
public void test() throws IOException
|
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();
|
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