use of net.runelite.cache.fs.Store in project runelite by runelite.
the class CacheServerTest method testServer.
@Test
public void testServer() throws Exception {
try (Store store = new Store(folder.newFolder());
CacheServer server = new CacheServer(store, REVISION)) {
addInitialFilesToStore(store);
store.save();
server.start();
try (Store store2 = new Store(folder.newFolder());
CacheClient client = new CacheClient(store2, HOST, REVISION)) {
client.connect();
client.handshake().get();
client.download();
Index index = store2.findIndex(0);
Archive archive = index.getArchive(0);
FileData[] files = archive.getFileData();
FileData file = files[0];
assertEquals(7, file.getNameHash());
Storage storage = store2.getStorage();
byte[] data = storage.loadArchive(archive);
data = archive.decompress(data);
assertArrayEquals("test".getBytes(), data);
assertEquals(store.getIndexes().get(0).getArchive(0).getCrc(), archive.getCrc());
}
}
}
use of net.runelite.cache.fs.Store in project runelite by runelite.
the class Cache method loadStore.
private static Store loadStore(String cache) throws IOException {
Store store = new Store(new File(cache));
store.load();
return store;
}
use of net.runelite.cache.fs.Store in project runelite by runelite.
the class Cache method main.
public static void main(String[] args) throws IOException {
Options options = new Options();
options.addOption("c", "cache", true, "cache base");
options.addOption(null, "items", true, "directory to dump items to");
options.addOption(null, "npcs", true, "directory to dump npcs to");
options.addOption(null, "objects", true, "directory to dump objects to");
options.addOption(null, "sprites", true, "directory to dump sprites to");
CommandLineParser parser = new DefaultParser();
CommandLine cmd;
try {
cmd = parser.parse(options, args);
} catch (ParseException ex) {
System.err.println("Error parsing command line options: " + ex.getMessage());
System.exit(-1);
return;
}
String cache = cmd.getOptionValue("cache");
Store store = loadStore(cache);
if (cmd.hasOption("items")) {
String itemdir = cmd.getOptionValue("items");
if (itemdir == null) {
System.err.println("Item directory must be specified");
return;
}
System.out.println("Dumping items to " + itemdir);
dumpItems(store, new File(itemdir));
} else if (cmd.hasOption("npcs")) {
String npcdir = cmd.getOptionValue("npcs");
if (npcdir == null) {
System.err.println("NPC directory must be specified");
return;
}
System.out.println("Dumping npcs to " + npcdir);
dumpNpcs(store, new File(npcdir));
} else if (cmd.hasOption("objects")) {
String objectdir = cmd.getOptionValue("objects");
if (objectdir == null) {
System.err.println("Object directory must be specified");
return;
}
System.out.println("Dumping objects to " + objectdir);
dumpObjects(store, new File(objectdir));
} else if (cmd.hasOption("sprites")) {
String spritedir = cmd.getOptionValue("sprites");
if (spritedir == null) {
System.err.println("Sprite directory must be specified");
return;
}
System.out.println("Dumping sprites to " + spritedir);
dumpSprites(store, new File(spritedir));
} else {
System.err.println("Nothing to do");
}
}
Aggregations