Search in sources :

Example 1 with FileEntry

use of net.runelite.http.service.cache.beans.FileEntry 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)

Aggregations

ArchiveFiles (net.runelite.cache.fs.ArchiveFiles)1 Container (net.runelite.cache.fs.Container)1 FSFile (net.runelite.cache.fs.FSFile)1 FileEntry (net.runelite.http.service.cache.beans.FileEntry)1 Connection (org.sql2o.Connection)1