From 5d51415bafc0a1c8487f1148464e2189b2d44148 Mon Sep 17 00:00:00 2001 From: Graham Date: Tue, 14 Jan 2020 21:17:02 +0000 Subject: [PATCH] Add write method to Resource --- bundler/src/main/java/dev/openrs2/bundler/Resource.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bundler/src/main/java/dev/openrs2/bundler/Resource.kt b/bundler/src/main/java/dev/openrs2/bundler/Resource.kt index 7336e66e..39859a16 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/Resource.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/Resource.kt @@ -1,7 +1,10 @@ package dev.openrs2.bundler +import com.github.michaelbull.logging.InlineLogger import dev.openrs2.asm.classpath.Library import java.io.ByteArrayOutputStream +import java.nio.file.Files +import java.nio.file.Path import java.security.MessageDigest import java.util.zip.CRC32 import java.util.zip.Deflater @@ -20,7 +23,15 @@ class Resource( require(digest.size == 20) } + fun write(dir: Path) { + val path = dir.resolve(source) + logger.info { "Writing resource $path" } + Files.write(path, content) + } + companion object { + private val logger = InlineLogger() + fun compress(source: String, destination: String, uncompressed: ByteArray): Resource { val crc = CRC32() crc.update(uncompressed)