byte[] clean = (cleanE != null ? ByteStreams.toByteArray(cleanJ.getInputStream(cleanE)) : new byte[0]);
byte[] dirty = ByteStreams.toByteArray(dirtyJ.getInputStream(dirtyE));
byte[] diff = delta.compute(clean, dirty);
ByteArrayDataOutput out = ByteStreams.newDataOutput(diff.length + 50);
out.writeUTF(obf); // Clean name
out.writeUTF(obf.replace('/', '.')); // Source Notch name
out.writeUTF(srg.replace('/', '.')); // Source SRG Name
out.writeBoolean(cleanE != null); // Exists in Clean
if (cleanE != null)
{
out.writeInt(adlerHash(clean)); // Hash of Clean file
}
out.writeInt(diff.length); // Patch length
out.write(diff); // Patch
patches.put(root + srg.replace('/', '.') + ".binpatch", out.toByteArray());
}
cleanJ.close();
dirtyJ.close();
}