store test of one file works
This commit is contained in:
64
src/main/java/net/runelite/cache/fs/Index.java
vendored
64
src/main/java/net/runelite/cache/fs/Index.java
vendored
@@ -41,6 +41,11 @@ public class Index implements Closeable
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
public List<Archive> getArchives()
|
||||
{
|
||||
return archives;
|
||||
}
|
||||
|
||||
public Archive addArchive(int id)
|
||||
{
|
||||
@@ -426,40 +431,41 @@ public class Index implements Closeable
|
||||
{
|
||||
File file = a.getFiles().get(0);
|
||||
stream.writeBytes(file.getContents());
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int count = 0; count < filesCount; ++count)
|
||||
else
|
||||
{
|
||||
File file = a.getFiles().get(count);
|
||||
//filesSize[count] += sourceOffset += stream.readInt();
|
||||
int sz = file.getSize() - sourceOffset;
|
||||
sourceOffset = file.getSize();
|
||||
stream.writeInt(sz);
|
||||
}
|
||||
|
||||
int prevLen = 0;
|
||||
for (int count = 0; count < filesCount; ++count)
|
||||
{
|
||||
File file = a.getFiles().get(count);
|
||||
//filesSize[count] += sourceOffset += stream.readInt();
|
||||
int sz = file.getSize() - sourceOffset;
|
||||
sourceOffset = file.getSize();
|
||||
stream.writeInt(sz);
|
||||
}
|
||||
|
||||
for (int i = 0; i < filesCount; ++i)
|
||||
{
|
||||
File file = a.getFiles().get(i);
|
||||
|
||||
int len = file.getSize() - prevLen;
|
||||
//int fid = file.getFileId() - fileId;
|
||||
//fileId = file.getFileId();
|
||||
stream.writeInt(len);
|
||||
prevLen = file.getSize();
|
||||
|
||||
stream.writeBytes(file.getContents());
|
||||
|
||||
// fileId += stream.readInt();
|
||||
// System.arraycopy(data, sourceOffset, var18[i], filesSize[i], fileId);
|
||||
// sourceOffset += fileId;
|
||||
// filesSize[i] += fileId;
|
||||
int prevLen = 0;
|
||||
|
||||
for (int i = 0; i < filesCount; ++i)
|
||||
{
|
||||
File file = a.getFiles().get(i);
|
||||
|
||||
int len = file.getSize() - prevLen;
|
||||
//int fid = file.getFileId() - fileId;
|
||||
//fileId = file.getFileId();
|
||||
stream.writeInt(len);
|
||||
prevLen = file.getSize();
|
||||
|
||||
stream.writeBytes(file.getContents());
|
||||
|
||||
// fileId += stream.readInt();
|
||||
// System.arraycopy(data, sourceOffset, var18[i], filesSize[i], fileId);
|
||||
// sourceOffset += fileId;
|
||||
// filesSize[i] += fileId;
|
||||
}
|
||||
|
||||
stream.writeByte(1); // number of loops
|
||||
}
|
||||
|
||||
stream.writeByte(1); // number of loops
|
||||
|
||||
byte[] fileData = new byte[stream.getOffset()];
|
||||
stream.setOffset(0);
|
||||
stream.getBytes(fileData, 0, fileData.length);
|
||||
|
||||
@@ -63,7 +63,7 @@ public class Store implements Closeable
|
||||
for (Index i : indexes)
|
||||
{
|
||||
int id = i.getIndex().getIndexFileId();
|
||||
if (id == 3 || id == 7) // XXXXXXXXXXXXX
|
||||
//if (id == 3 || id == 7) // XXXXXXXXXXXXX
|
||||
i.load();
|
||||
}
|
||||
}
|
||||
@@ -83,4 +83,9 @@ public class Store implements Closeable
|
||||
{
|
||||
return index255;
|
||||
}
|
||||
|
||||
public List<Index> getIndexes()
|
||||
{
|
||||
return indexes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.runelite.cache.fs;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -14,12 +16,41 @@ public class StoreTest
|
||||
@BeforeClass
|
||||
public static void before()
|
||||
{
|
||||
System.setProperty("java.io.tmpdir", "d:/temp");
|
||||
System.setProperty("java.io.tmpdir", "c:/rs/temp");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreate() throws IOException
|
||||
public void test() throws IOException
|
||||
{
|
||||
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