Search in sources :

Example 36 with Store

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());
        }
    }
}
Also used : CacheClient(net.runelite.cache.client.CacheClient) Archive(net.runelite.cache.fs.Archive) Storage(net.runelite.cache.fs.Storage) Store(net.runelite.cache.fs.Store) Index(net.runelite.cache.fs.Index) FileData(net.runelite.cache.index.FileData) Test(org.junit.Test)

Example 37 with Store

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;
}
Also used : Store(net.runelite.cache.fs.Store) File(java.io.File)

Example 38 with 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");
    }
}
Also used : Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) Store(net.runelite.cache.fs.Store) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) File(java.io.File) DefaultParser(org.apache.commons.cli.DefaultParser)

Aggregations

Store (net.runelite.cache.fs.Store)38 File (java.io.File)34 Test (org.junit.Test)32 Archive (net.runelite.cache.fs.Archive)21 Index (net.runelite.cache.fs.Index)20 Storage (net.runelite.cache.fs.Storage)18 ArchiveFiles (net.runelite.cache.fs.ArchiveFiles)9 FSFile (net.runelite.cache.fs.FSFile)9 Ignore (org.junit.Ignore)7 BufferedImage (java.awt.image.BufferedImage)4 IOException (java.io.IOException)3 CacheClient (net.runelite.cache.client.CacheClient)3 ModelLoader (net.runelite.cache.definitions.loaders.ModelLoader)3 TextureManager (net.runelite.cache.TextureManager)2 FramemapDefinition (net.runelite.cache.definitions.FramemapDefinition)2 ModelDefinition (net.runelite.cache.definitions.ModelDefinition)2 FramemapLoader (net.runelite.cache.definitions.loaders.FramemapLoader)2 FileData (net.runelite.cache.index.FileData)2 HandshakeResponseType (net.runelite.protocol.api.login.HandshakeResponseType)2 RemoteCache (com.ostracker.cache.RemoteCache)1