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;
}
}
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;
}
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);
}
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;
}
Aggregations