Exclude CRC from the path used by Resource::write

bzip2
Graham 5 years ago
parent d03d1c3bb5
commit a032e3d472
  1. 8
      bundler/src/main/java/dev/openrs2/bundler/Resource.kt
  2. 2
      bundler/src/main/java/dev/openrs2/bundler/transform/ResourceTransformer.kt

@ -12,10 +12,14 @@ import java.util.zip.Deflater
class Resource(
val source: String,
val destination: String,
val crc: Int,
val digest: ByteArray,
val uncompressedSize: Int,
val content: ByteArray
) {
val sourceWithCrc: String
get() = source.replace(".", "_$crc.")
val compressedSize: Int
get() = content.size
@ -36,8 +40,6 @@ class Resource(
val crc = CRC32()
crc.update(uncompressed)
val sourceWithCrc = source.replace(".", "_${crc.value.toInt()}.")
val digest = MessageDigest.getInstance("SHA-1")
digest.update(uncompressed)
@ -59,7 +61,7 @@ class Resource(
uncompressed
}
return Resource(sourceWithCrc, destination, digest.digest(), uncompressed.size, content)
return Resource(source, destination, crc.value.toInt(), digest.digest(), uncompressed.size, content)
}
fun compressJar(source: String, destination: String, library: Library): Resource {

@ -112,7 +112,7 @@ class ResourceTransformer(
list.add(TypeInsnNode(Opcodes.NEW, type))
list.add(InsnNode(Opcodes.DUP))
list.add(LdcInsnNode(resource.destination))
list.add(LdcInsnNode(resource.source))
list.add(LdcInsnNode(resource.sourceWithCrc))
list.add(createIntConstant(messages.size))
list.add(TypeInsnNode(Opcodes.ANEWARRAY, "java/lang/String"))

Loading…
Cancel
Save