Put Indexes in store, and indexfile in index
This commit is contained in:
16
src/main/java/net/runelite/cache/fs/Index.java
vendored
16
src/main/java/net/runelite/cache/fs/Index.java
vendored
@@ -1,5 +1,6 @@
|
|||||||
package net.runelite.cache.fs;
|
package net.runelite.cache.fs;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -9,8 +10,9 @@ import net.runelite.cache.fs.io.OutputStream;
|
|||||||
import net.runelite.cache.fs.util.bzip2.BZip2Decompressor;
|
import net.runelite.cache.fs.util.bzip2.BZip2Decompressor;
|
||||||
import net.runelite.cache.fs.util.gzip.GZipDecompressor;
|
import net.runelite.cache.fs.util.gzip.GZipDecompressor;
|
||||||
|
|
||||||
public class Index
|
public class Index implements Closeable
|
||||||
{
|
{
|
||||||
|
private final Store store;
|
||||||
private final IndexFile index;
|
private final IndexFile index;
|
||||||
private final int id;
|
private final int id;
|
||||||
private int compression;
|
private int compression;
|
||||||
@@ -20,16 +22,24 @@ public class Index
|
|||||||
private byte[] whirlpool;
|
private byte[] whirlpool;
|
||||||
private List<Archive> archives = new ArrayList<>();
|
private List<Archive> archives = new ArrayList<>();
|
||||||
|
|
||||||
public Index(IndexFile index, int id)
|
public Index(Store store, IndexFile index, int id)
|
||||||
{
|
{
|
||||||
|
this.store = store;
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException
|
||||||
|
{
|
||||||
|
index.close();
|
||||||
|
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||||
|
}
|
||||||
|
|
||||||
public void load() throws IOException
|
public void load() throws IOException
|
||||||
{
|
{
|
||||||
// read data from index255
|
// read data from index255
|
||||||
Store store = index.getStore();
|
//Store store = index.getStore();
|
||||||
DataFile dataFile = store.getData();
|
DataFile dataFile = store.getData();
|
||||||
IndexFile index255 = store.getIndex255();
|
IndexFile index255 = store.getIndex255();
|
||||||
|
|
||||||
|
|||||||
20
src/main/java/net/runelite/cache/fs/Store.java
vendored
20
src/main/java/net/runelite/cache/fs/Store.java
vendored
@@ -14,7 +14,8 @@ public class Store implements Closeable
|
|||||||
|
|
||||||
private final DataFile data;
|
private final DataFile data;
|
||||||
private final IndexFile index255;
|
private final IndexFile index255;
|
||||||
private final List<IndexFile> indexFiles = 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
|
||||||
{
|
{
|
||||||
@@ -22,7 +23,13 @@ public class Store implements Closeable
|
|||||||
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"));
|
||||||
|
|
||||||
for (int i = 0; i < index255.getIndexCount(); ++i)
|
for (int i = 0; i < index255.getIndexCount(); ++i)
|
||||||
indexFiles.add(new IndexFile(this, i, new File(folder, MAIN_FILE_CACHE_IDX + i)));
|
{
|
||||||
|
IndexFile ifile = new IndexFile(this, i, new File(folder, MAIN_FILE_CACHE_IDX + i));
|
||||||
|
Index index = new Index(this, ifile, i);
|
||||||
|
|
||||||
|
indexes.add(index);
|
||||||
|
}
|
||||||
|
//indexFiles.add(new IndexFile(this, i, new File(folder, MAIN_FILE_CACHE_IDX + i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -30,10 +37,17 @@ public class Store implements Closeable
|
|||||||
{
|
{
|
||||||
data.close();
|
data.close();
|
||||||
index255.close();
|
index255.close();
|
||||||
for (IndexFile i : indexFiles)
|
for (Index i : indexes)
|
||||||
|
//for (IndexFile i : indexFiles)
|
||||||
i.close();
|
i.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void load() throws IOException
|
||||||
|
{
|
||||||
|
for (Index i : indexes)
|
||||||
|
i.load();
|
||||||
|
}
|
||||||
|
|
||||||
public DataFile getData()
|
public DataFile getData()
|
||||||
{
|
{
|
||||||
return data;
|
return data;
|
||||||
|
|||||||
Reference in New Issue
Block a user