Skip to content

Commit 8098305

Browse files
authored
🔀 Merge pull request #339 from vinceglb/fix-readbytes-closable-issue
⚡️ Fix readBytes and readString methods to ensure proper resource management
2 parents 2fb8dec + 7a3325f commit 8098305

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.run/SampleCore Jvm.run.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="SampleCore Jvm" type="GradleRunConfiguration" factoryName="Gradle">
33
<ExternalSystemSettings>
4+
<option name="env">
5+
<map>
6+
<entry key="DEVELOPER_DIR" value="/Applications/Xcode.app/Contents/Developer" />
7+
</map>
8+
</option>
49
<option name="executionName" />
510
<option name="externalProjectPath" value="$PROJECT_DIR$" />
611
<option name="externalSystemIdString" value="GRADLE" />

filekit-core/src/nonWebMain/kotlin/io/github/vinceglb/filekit/PlatformFile.nonWeb.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ public actual suspend fun PlatformFile.readBytes(): ByteArray =
4747
this@readBytes
4848
.source()
4949
.buffered()
50-
.readByteArray()
50+
.use { it.readByteArray() }
5151
}
5252

5353
public actual suspend fun PlatformFile.readString(): String =
5454
withContext(Dispatchers.IO) {
5555
this@readString
5656
.source()
5757
.buffered()
58-
.readString()
58+
.use { it.readString() }
5959
}
6060

6161
public suspend infix fun PlatformFile.write(bytes: ByteArray): Unit =

0 commit comments

Comments
 (0)