store test of one file works
This commit is contained in:
10
src/main/java/net/runelite/cache/fs/Index.java
vendored
10
src/main/java/net/runelite/cache/fs/Index.java
vendored
@@ -42,6 +42,11 @@ public class Index implements Closeable
|
|||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Archive> getArchives()
|
||||||
|
{
|
||||||
|
return archives;
|
||||||
|
}
|
||||||
|
|
||||||
public Archive addArchive(int id)
|
public Archive addArchive(int id)
|
||||||
{
|
{
|
||||||
Archive archive = new Archive(this, id);
|
Archive archive = new Archive(this, id);
|
||||||
@@ -426,9 +431,9 @@ public class Index implements Closeable
|
|||||||
{
|
{
|
||||||
File file = a.getFiles().get(0);
|
File file = a.getFiles().get(0);
|
||||||
stream.writeBytes(file.getContents());
|
stream.writeBytes(file.getContents());
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
for (int count = 0; count < filesCount; ++count)
|
for (int count = 0; count < filesCount; ++count)
|
||||||
{
|
{
|
||||||
File file = a.getFiles().get(count);
|
File file = a.getFiles().get(count);
|
||||||
@@ -459,6 +464,7 @@ public class Index implements Closeable
|
|||||||
}
|
}
|
||||||
|
|
||||||
stream.writeByte(1); // number of loops
|
stream.writeByte(1); // number of loops
|
||||||
|
}
|
||||||
|
|
||||||
byte[] fileData = new byte[stream.getOffset()];
|
byte[] fileData = new byte[stream.getOffset()];
|
||||||
stream.setOffset(0);
|
stream.setOffset(0);
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class Store implements Closeable
|
|||||||
for (Index i : indexes)
|
for (Index i : indexes)
|
||||||
{
|
{
|
||||||
int id = i.getIndex().getIndexFileId();
|
int id = i.getIndex().getIndexFileId();
|
||||||
if (id == 3 || id == 7) // XXXXXXXXXXXXX
|
//if (id == 3 || id == 7) // XXXXXXXXXXXXX
|
||||||
i.load();
|
i.load();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,4 +83,9 @@ public class Store implements Closeable
|
|||||||
{
|
{
|
||||||
return index255;
|
return index255;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Index> getIndexes()
|
||||||
|
{
|
||||||
|
return indexes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package net.runelite.cache.fs;
|
package net.runelite.cache.fs;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -14,12 +16,41 @@ public class StoreTest
|
|||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void before()
|
public static void before()
|
||||||
{
|
{
|
||||||
System.setProperty("java.io.tmpdir", "d:/temp");
|
System.setProperty("java.io.tmpdir", "c:/rs/temp");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreate() throws IOException
|
public void test() throws IOException
|
||||||
{
|
{
|
||||||
Store store = new Store(folder.getRoot());
|
Store store = new Store(folder.getRoot());
|
||||||
|
Index index = store.addIndex(0);
|
||||||
|
Archive archive = index.addArchive(0);
|
||||||
|
File file = archive.addFile(0);
|
||||||
|
file.setContents("test".getBytes());
|
||||||
|
|
||||||
|
store.save();
|
||||||
|
|
||||||
|
store.close();
|
||||||
|
|
||||||
|
store = new Store(folder.getRoot());
|
||||||
|
store.load();
|
||||||
|
|
||||||
|
List<Index> indexes = store.getIndexes();
|
||||||
|
Assert.assertEquals(1, indexes.size());
|
||||||
|
|
||||||
|
index = indexes.get(0);
|
||||||
|
List<Archive> archives = index.getArchives();
|
||||||
|
Assert.assertEquals(1, archives.size());
|
||||||
|
|
||||||
|
archive = archives.get(0);
|
||||||
|
List<File> files = archive.getFiles();
|
||||||
|
// XXX just use equals methods on store duh
|
||||||
|
//archive.
|
||||||
|
|
||||||
|
File file2 = files.get(0);
|
||||||
|
|
||||||
|
Assert.assertArrayEquals(file.getContents(), file2.getContents());
|
||||||
|
|
||||||
|
System.out.println(store);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user