Skip to content

Commit

Permalink
open file in binary mode to avoid line conversion issues
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlieTap committed Mar 27, 2024
1 parent 9d14d28 commit 9e7809d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions resources-library/src/posixMain/kotlin/Resource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public actual class Resource actual constructor(private val path: String) {
public actual fun exists(): Boolean = access(path, F_OK) != -1

public actual fun readText(): String = buildString {
val file = fopen(path, "rb")
val file = fopen(path, "r")
?: throw FileReadException("$path: Open failed: ${strerror(posix_errno())}")
try {
memScoped {
Expand All @@ -33,7 +33,7 @@ public actual class Resource actual constructor(private val path: String) {
}

public actual fun readBytes(): ByteArray = mutableListOf<Byte>().apply {
val file = fopen(path, "r")
val file = fopen(path, "rb")
?: throw FileReadException("$path: Open failed: ${strerror(posix_errno())}")
try {
memScoped {
Expand Down

0 comments on commit 9e7809d

Please sign in to comment.