use of net.runelite.cache.index.FileData in project runelite by runelite.
the class StoreTest method testMultipleArchives.
@Test
public void testMultipleArchives() throws IOException {
Random random = new Random(43L);
File root = folder.newFolder();
try (Store store = new Store(root)) {
Index index = store.addIndex(0);
Index index2 = store.addIndex(1);
Archive archive = index.addArchive(0);
archive.setNameHash(random.nextInt(Integer.MAX_VALUE));
archive.setFileData(new FileData[NUMBER_OF_FILES]);
Archive archive2 = index.addArchive(1);
archive2.setFileData(new FileData[NUMBER_OF_FILES]);
Archive archive3 = index2.addArchive(0);
archive3.setFileData(new FileData[NUMBER_OF_FILES]);
for (int i = 0; i < NUMBER_OF_FILES; ++i) {
FileData[] fileData = archive.getFileData();
FileData file = fileData[i] = new FileData();
file.setNameHash(random.nextInt(Integer.MAX_VALUE));
}
for (int i = 0; i < NUMBER_OF_FILES; ++i) {
FileData[] fileData = archive2.getFileData();
FileData file = fileData[i] = new FileData();
file.setNameHash(random.nextInt(Integer.MAX_VALUE));
}
for (int i = 0; i < NUMBER_OF_FILES; ++i) {
FileData[] fileData = archive3.getFileData();
FileData file = fileData[i] = new FileData();
file.setNameHash(random.nextInt(Integer.MAX_VALUE));
}
store.save();
try (Store store2 = new Store(root)) {
store2.load();
Assert.assertEquals(store, store2);
}
}
}
use of net.runelite.cache.index.FileData in project runelite by runelite.
the class StoreTest method testOneFile.
@Test
public void testOneFile() throws IOException {
try (Store store = new Store(folder.getRoot())) {
Index index = store.addIndex(0);
Archive archive = index.addArchive(0);
archive.setFileData(new FileData[1]);
FileData fileData = archive.getFileData()[0] = new FileData();
fileData.setId(42);
fileData.setNameHash(7);
store.save();
try (Store store2 = new Store(folder.getRoot())) {
store2.load();
Assert.assertEquals(store, store2);
}
}
}
use of net.runelite.cache.index.FileData in project runelite by runelite.
the class Archive method getFiles.
public ArchiveFiles getFiles(byte[] data, int[] keys) throws IOException {
byte[] decompressedData = decompress(data, keys);
ArchiveFiles files = new ArchiveFiles();
for (FileData fileEntry : fileData) {
FSFile file = new FSFile(fileEntry.getId());
file.setNameHash(fileEntry.getNameHash());
files.addFile(file);
}
files.loadContents(decompressedData);
return files;
}
use of net.runelite.cache.index.FileData in project runelite by runelite.
the class Index method toIndexData.
public IndexData toIndexData() {
IndexData data = new IndexData();
data.setProtocol(protocol);
data.setRevision(revision);
data.setNamed(named);
ArchiveData[] archiveDatas = new ArchiveData[archives.size()];
data.setArchives(archiveDatas);
int idx = 0;
for (Archive archive : archives) {
ArchiveData ad = archiveDatas[idx++] = new ArchiveData();
ad.setId(archive.getArchiveId());
ad.setNameHash(archive.getNameHash());
ad.setCrc(archive.getCrc());
ad.setRevision(archive.getRevision());
FileData[] files = archive.getFileData();
ad.setFiles(files);
}
return data;
}
use of net.runelite.cache.index.FileData in project runelite by runelite.
the class StoreTest method testManyFiles.
@Test
public void testManyFiles() throws IOException {
Random random = new Random(42L);
File root = folder.newFolder();
try (Store store = new Store(root)) {
Index index = store.addIndex(0);
Archive archive = index.addArchive(0);
archive.setNameHash(random.nextInt());
archive.setFileData(new FileData[NUMBER_OF_FILES]);
for (int i = 0; i < NUMBER_OF_FILES; ++i) {
FileData[] fileData = archive.getFileData();
FileData file = fileData[i] = new FileData();
file.setId(i);
file.setNameHash(random.nextInt());
}
store.save();
try (Store store2 = new Store(root)) {
store2.load();
Assert.assertEquals(store, store2);
}
}
}
Aggregations