Put Indexes in store, and indexfile in index

This commit is contained in:
Adam
2015-10-14 10:02:09 -04:00
parent 634d5ec325
commit df2db1c84c
2 changed files with 30 additions and 6 deletions

View File

@@ -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();

View File

@@ -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,9 +37,16 @@ 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()
{ {