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