Search in sources :

Example 11 with Container

use of net.runelite.cache.fs.Container in project runelite by runelite.

the class CacheService method getArchiveFiles.

public ArchiveFiles getArchiveFiles(ArchiveEntry archiveEntry) throws IOException {
    CacheDAO cacheDao = new CacheDAO();
    try (Connection con = sql2o.open();
        ResultSetIterable<FileEntry> files = cacheDao.findFilesForArchive(con, archiveEntry)) {
        byte[] archiveData = getArchive(archiveEntry);
        if (archiveData == null) {
            return null;
        }
        Container result = Container.decompress(archiveData, null);
        if (result == null) {
            return null;
        }
        byte[] decompressedData = result.data;
        ArchiveFiles archiveFiles = new ArchiveFiles();
        for (FileEntry fileEntry : files) {
            FSFile file = new FSFile(fileEntry.getFileId());
            archiveFiles.addFile(file);
            file.setNameHash(fileEntry.getNameHash());
        }
        archiveFiles.loadContents(decompressedData);
        return archiveFiles;
    }
}
Also used : Container(net.runelite.cache.fs.Container) ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) Connection(org.sql2o.Connection) FileEntry(net.runelite.http.service.cache.beans.FileEntry) FSFile(net.runelite.cache.fs.FSFile)

Example 12 with Container

use of net.runelite.cache.fs.Container in project runelite by runelite.

the class ArchiveRequestHandler method compress.

private byte[] compress(int compression, byte[] data) throws IOException {
    Container container = new Container(compression, -1);
    container.compress(data, null);
    return container.data;
}
Also used : Container(net.runelite.cache.fs.Container)

Example 13 with Container

use of net.runelite.cache.fs.Container in project runelite by runelite.

the class CacheServerTest method addInitialFilesToStore.

private void addInitialFilesToStore(Store store) throws FileNotFoundException, IOException {
    Storage storage = store.getStorage();
    Index index = store.addIndex(0);
    Archive archive = index.addArchive(0);
    FileData[] files = new FileData[1];
    archive.setFileData(files);
    FileData file = files[0] = new FileData();
    file.setNameHash(7);
    byte[] data = "test".getBytes();
    Container container = new Container(archive.getCompression(), -1);
    container.compress(data, null);
    byte[] compressedData = container.data;
    storage.saveArchive(archive, compressedData);
}
Also used : Container(net.runelite.cache.fs.Container) Storage(net.runelite.cache.fs.Storage) Archive(net.runelite.cache.fs.Archive) Index(net.runelite.cache.fs.Index) FileData(net.runelite.cache.index.FileData)

Example 14 with Container

use of net.runelite.cache.fs.Container in project runelite by runelite.

the class FileResult method decompress.

public void decompress(int[] keys) throws IOException {
    Container res = Container.decompress(compressedData, keys);
    contents = res.data;
    revision = res.revision;
    crc = res.crc;
    compression = res.compression;
}
Also used : Container(net.runelite.cache.fs.Container)

Aggregations

Container (net.runelite.cache.fs.Container)14 Test (org.junit.Test)8 File (java.io.File)5 Archive (net.runelite.cache.fs.Archive)3 Index (net.runelite.cache.fs.Index)2 FileData (net.runelite.cache.index.FileData)2 IndexData (net.runelite.cache.index.IndexData)2 ByteBuf (io.netty.buffer.ByteBuf)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 ArchiveFiles (net.runelite.cache.fs.ArchiveFiles)1 FSFile (net.runelite.cache.fs.FSFile)1 Storage (net.runelite.cache.fs.Storage)1 Store (net.runelite.cache.fs.Store)1 ArchiveData (net.runelite.cache.index.ArchiveData)1 Crc32 (net.runelite.cache.util.Crc32)1 FileEntry (net.runelite.http.service.cache.beans.FileEntry)1 ArchiveResponsePacket (net.runelite.protocol.api.update.ArchiveResponsePacket)1 ArchiveResponseDecoder (net.runelite.protocol.update.decoders.ArchiveResponseDecoder)1 Connection (org.sql2o.Connection)1