diff --git a/src/main/java/net/runelite/cache/fs/Index.java b/src/main/java/net/runelite/cache/fs/Index.java index dca8e03a90..0bf718592f 100644 --- a/src/main/java/net/runelite/cache/fs/Index.java +++ b/src/main/java/net/runelite/cache/fs/Index.java @@ -1,5 +1,6 @@ package net.runelite.cache.fs; +import java.io.Closeable; import java.io.IOException; import java.nio.ByteBuffer; 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.gzip.GZipDecompressor; -public class Index +public class Index implements Closeable { + private final Store store; private final IndexFile index; private final int id; private int compression; @@ -20,16 +22,24 @@ public class Index private byte[] whirlpool; private List archives = new ArrayList<>(); - public Index(IndexFile index, int id) + public Index(Store store, IndexFile index, int id) { + this.store = store; this.index = index; 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 { // read data from index255 - Store store = index.getStore(); + //Store store = index.getStore(); DataFile dataFile = store.getData(); IndexFile index255 = store.getIndex255(); diff --git a/src/main/java/net/runelite/cache/fs/Store.java b/src/main/java/net/runelite/cache/fs/Store.java index 2f0acb9942..844e20e4f7 100644 --- a/src/main/java/net/runelite/cache/fs/Store.java +++ b/src/main/java/net/runelite/cache/fs/Store.java @@ -14,7 +14,8 @@ public class Store implements Closeable private final DataFile data; private final IndexFile index255; - private final List indexFiles = new ArrayList<>(); + private final List indexes = new ArrayList<>(); + //private final List indexFiles = new ArrayList<>(); 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")); 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 @@ -30,9 +37,16 @@ public class Store implements Closeable { data.close(); index255.close(); - for (IndexFile i : indexFiles) + for (Index i : indexes) + //for (IndexFile i : indexFiles) i.close(); } + + public void load() throws IOException + { + for (Index i : indexes) + i.load(); + } public DataFile getData() {