Init of store loading, what is datafile id
This commit is contained in:
33
src/main/java/net/runelite/cache/fs/Store.java
vendored
33
src/main/java/net/runelite/cache/fs/Store.java
vendored
@@ -1,5 +1,36 @@
|
||||
package net.runelite.cache.fs;
|
||||
|
||||
public class Store
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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 DataFile data;
|
||||
private final IndexFile index255;
|
||||
private final List<IndexFile> indexFiles = new ArrayList<>();
|
||||
|
||||
public Store(File folder) throws IOException
|
||||
{
|
||||
data = new DataFile(this, -1/*wtfisthis*/, new File(folder, MAIN_FILE_CACHE_DAT));
|
||||
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)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException
|
||||
{
|
||||
data.close();
|
||||
index255.close();
|
||||
for (IndexFile i : indexFiles)
|
||||
i.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class DataFileTest
|
||||
public void test1() throws IOException
|
||||
{
|
||||
File file = folder.newFile();
|
||||
Store store = new Store();
|
||||
Store store = new Store(folder.getRoot());
|
||||
DataFile df = new DataFile(store, 42, file);
|
||||
int sector = df.write(3, ByteBuffer.wrap("test".getBytes()));
|
||||
ByteBuffer buf = df.read(3, sector, 4);
|
||||
@@ -33,7 +33,7 @@ public class DataFileTest
|
||||
for (int i = 0; i < 1024; ++i) b[i] = (byte) i;
|
||||
|
||||
File file = folder.newFile();
|
||||
Store store = new Store();
|
||||
Store store = new Store(folder.getRoot());
|
||||
DataFile df = new DataFile(store, 42, file);
|
||||
int sector = df.write(0x1FFFF, ByteBuffer.wrap(b));
|
||||
ByteBuffer buf = df.read(0x1FFFF, sector, b.length);
|
||||
|
||||
@@ -16,7 +16,7 @@ public class IndexFileTest
|
||||
public void test1() throws IOException
|
||||
{
|
||||
File file = folder.newFile();
|
||||
Store store = new Store();
|
||||
Store store = new Store(folder.getRoot());
|
||||
IndexFile index = new IndexFile(store, 5, file);
|
||||
IndexEntry entry = new IndexEntry(index, 7, 8, 9);
|
||||
index.write(entry);
|
||||
|
||||
Reference in New Issue
Block a user