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