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;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Archive> getArchives()
|
||||||
|
{
|
||||||
|
return archives;
|
||||||
|
}
|
||||||
|
|
||||||
public Archive addArchive(int id)
|
public Archive addArchive(int id)
|
||||||
{
|
{
|
||||||
@@ -426,40 +431,41 @@ 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)
|
|
||||||
{
|
{
|
||||||
File file = a.getFiles().get(count);
|
for (int count = 0; count < filesCount; ++count)
|
||||||
//filesSize[count] += sourceOffset += stream.readInt();
|
{
|
||||||
int sz = file.getSize() - sourceOffset;
|
File file = a.getFiles().get(count);
|
||||||
sourceOffset = file.getSize();
|
//filesSize[count] += sourceOffset += stream.readInt();
|
||||||
stream.writeInt(sz);
|
int sz = file.getSize() - sourceOffset;
|
||||||
}
|
sourceOffset = file.getSize();
|
||||||
|
stream.writeInt(sz);
|
||||||
int prevLen = 0;
|
}
|
||||||
|
|
||||||
for (int i = 0; i < filesCount; ++i)
|
int prevLen = 0;
|
||||||
{
|
|
||||||
File file = a.getFiles().get(i);
|
for (int i = 0; i < filesCount; ++i)
|
||||||
|
{
|
||||||
int len = file.getSize() - prevLen;
|
File file = a.getFiles().get(i);
|
||||||
//int fid = file.getFileId() - fileId;
|
|
||||||
//fileId = file.getFileId();
|
int len = file.getSize() - prevLen;
|
||||||
stream.writeInt(len);
|
//int fid = file.getFileId() - fileId;
|
||||||
prevLen = file.getSize();
|
//fileId = file.getFileId();
|
||||||
|
stream.writeInt(len);
|
||||||
stream.writeBytes(file.getContents());
|
prevLen = file.getSize();
|
||||||
|
|
||||||
// fileId += stream.readInt();
|
stream.writeBytes(file.getContents());
|
||||||
// System.arraycopy(data, sourceOffset, var18[i], filesSize[i], fileId);
|
|
||||||
// sourceOffset += fileId;
|
// fileId += stream.readInt();
|
||||||
// filesSize[i] += fileId;
|
// 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()];
|
byte[] fileData = new byte[stream.getOffset()];
|
||||||
stream.setOffset(0);
|
stream.setOffset(0);
|
||||||
stream.getBytes(fileData, 0, fileData.length);
|
stream.getBytes(fileData, 0, fileData.length);
|
||||||
|
|||||||
@@ -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