Skip to content

Commit fa0d5bd

Browse files
committed
Fixed file mode
1 parent e8565bd commit fa0d5bd

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

core/common/src/files/Paths.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import kotlinx.io.Source
1111
/**
1212
* A wrapper around a string representing a file path allowing to read from and write to a
1313
* corresponding file using [Sink] and [Source].
14+
*
15+
* **This API is unstable and subject to change.**
1416
*/
1517
public expect class Path
1618

core/native/src/files/PathsNative.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ public actual class Path internal constructor(internal val path: String,
1919
public actual fun Path(path: String): Path = Path(path, null)
2020

2121
public actual fun Path.source(): Source {
22-
val openFile: CPointer<FILE> = fopen(path, "r")
22+
val openFile: CPointer<FILE> = fopen(path, "rb")
2323
?: throw IOException("Failed to open $path with ${strerror(errno)?.toKString()}")
2424
return FileSource(openFile).buffered()
2525
}
2626

2727
public actual fun Path.sink(): Sink {
28-
val openFile: CPointer<FILE> = fopen(path, "w")
28+
val openFile: CPointer<FILE> = fopen(path, "wb")
2929
?: throw IOException("Failed to open $path with ${strerror(errno)?.toKString()}")
3030
return FileSink(openFile).buffered()
3131
}

0 commit comments

Comments
 (0)