deprecate some input stream methods

Ported to kutil 1.26
This commit is contained in:
Moritz Zwerger 2024-01-12 14:39:55 +01:00
parent 58989aed8e
commit 94954657ca
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 6 additions and 2 deletions

View File

@ -72,6 +72,7 @@ object FileUtil {
throw IOException("Can not find temporary file after ${AssetsOptions.MAX_FILE_CHECKING} tries!") throw IOException("Can not find temporary file after ${AssetsOptions.MAX_FILE_CHECKING} tries!")
} }
@Deprecated("kutil 1.26")
fun InputStream.copy(vararg output: OutputStream, digest: MessageDigest?) { fun InputStream.copy(vararg output: OutputStream, digest: MessageDigest?) {
val buffer = ByteArray(BufferDefinition.DEFAULT_BUFFER_SIZE) val buffer = ByteArray(BufferDefinition.DEFAULT_BUFFER_SIZE)

View File

@ -18,6 +18,7 @@ import com.fasterxml.jackson.databind.ObjectReader
import com.fasterxml.jackson.module.kotlin.readValue import com.fasterxml.jackson.module.kotlin.readValue
import de.bixilon.kutil.buffer.BufferDefinition import de.bixilon.kutil.buffer.BufferDefinition
import de.bixilon.kutil.cast.CastUtil.unsafeCast import de.bixilon.kutil.cast.CastUtil.unsafeCast
import de.bixilon.kutil.exception.ExceptionUtil.ignoreAll
import de.bixilon.kutil.json.JsonObject import de.bixilon.kutil.json.JsonObject
import de.bixilon.mbf.MBFBinaryReader import de.bixilon.mbf.MBFBinaryReader
import de.bixilon.minosoft.util.json.Jackson import de.bixilon.minosoft.util.json.Jackson
@ -27,6 +28,7 @@ import java.util.zip.ZipInputStream
object InputStreamUtil { object InputStreamUtil {
@Deprecated("kutil 1.26")
fun InputStream.readAsString(close: Boolean = true): String { fun InputStream.readAsString(close: Boolean = true): String {
val builder = StringBuilder() val builder = StringBuilder()
@ -89,7 +91,7 @@ object InputStreamUtil {
content[entry.name] = stream.readAll() content[entry.name] = stream.readAll()
} }
// TODO: handle exception // TODO: handle exception
if (close) close() if (close) ignoreAll { close() }
return content return content
} }
@ -101,7 +103,7 @@ object InputStreamUtil {
content[entry.name] = stream.readAll() content[entry.name] = stream.readAll()
} }
// TODO: handle exception // TODO: handle exception
if (close) close() if (close) ignoreAll { close() }
return content return content
} }
@ -109,6 +111,7 @@ object InputStreamUtil {
return this.use { MBFBinaryReader(this).readMBF().data.unsafeCast() } return this.use { MBFBinaryReader(this).readMBF().data.unsafeCast() }
} }
@Deprecated("kutil 1.26")
fun InputStream.readAll(close: Boolean = true): ByteArray { fun InputStream.readAll(close: Boolean = true): ByteArray {
if (close) { if (close) {
return use { readAllBytes() } return use { readAllBytes() }