Skip to content

Commit

Permalink
fix(Resources): Use readNBytes() to read a chunk of resources JetBrai…
Browse files Browse the repository at this point in the history
  • Loading branch information
AChep authored Jun 7, 2024
1 parent fc90219 commit fe15837
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ internal actual fun getPlatformResourceReader(): ResourceReader = object : Resou

override suspend fun readPart(path: String, offset: Long, size: Long): ByteArray {
val resource = getResourceAsStream(path)
val result = ByteArray(size.toInt())
resource.use { input ->
return resource.use { input ->
input.skip(offset)
input.read(result, 0, size.toInt())
input.readNBytes(size.toInt())
}
return result
}

override fun getUri(path: String): String {
Expand All @@ -32,4 +30,4 @@ internal actual fun getPlatformResourceReader(): ResourceReader = object : Resou
private fun getClassLoader(): ClassLoader {
return this.javaClass.classLoader ?: error("Cannot find class loader")
}
}
}

0 comments on commit fe15837

Please sign in to comment.