Search in sources :

Example 11 with OutputStream

use of net.runelite.cache.io.OutputStream in project runelite by runelite.

the class ArchiveFiles method saveContents.

public byte[] saveContents() {
    OutputStream stream = new OutputStream();
    int filesCount = this.getFiles().size();
    if (filesCount == 1) {
        FSFile file = this.getFiles().get(0);
        stream.writeBytes(file.getContents());
    } else {
        for (FSFile file : this.getFiles()) {
            byte[] contents = file.getContents();
            stream.writeBytes(contents);
        }
        int offset = 0;
        for (FSFile file : this.getFiles()) {
            int chunkSize = file.getSize();
            int sz = chunkSize - offset;
            offset = chunkSize;
            stream.writeInt(sz);
        }
        // chunks
        stream.writeByte(1);
    }
    byte[] fileData = stream.flip();
    logger.trace("Saved contents of archive ({} files), {} bytes", files.size(), fileData.length);
    return fileData;
}
Also used : OutputStream(net.runelite.cache.io.OutputStream)

Aggregations

OutputStream (net.runelite.cache.io.OutputStream)11 Map (java.util.Map)3 ArrayList (java.util.ArrayList)1 Tile (net.runelite.cache.definitions.MapDefinition.Tile)1 Location (net.runelite.cache.region.Location)1