Skip to content

Commit 76506b0

Browse files
committed
Cleanup
1 parent a23f789 commit 76506b0

File tree

7 files changed

+5
-30
lines changed

7 files changed

+5
-30
lines changed

core/apple/test/NSInputStreamSourceTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package kotlinx.io
77

8+
import kotlinx.io.files.FileSystem
89
import kotlinx.io.files.Path
910
import kotlinx.io.files.sink
1011
import platform.Foundation.NSInputStream
@@ -38,7 +39,7 @@ class NSInputStreamSourceTest {
3839
assertEquals(7, source.readAtMostTo(buffer, 10))
3940
assertEquals("example", buffer.readString())
4041
} finally {
41-
deleteFile(file)
42+
FileSystem.System.delete(Path(file))
4243
}
4344
}
4445

core/common/src/files/Paths.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public expect fun Path.source(): Source
110110
* overwrites contents.
111111
*/
112112
@Deprecated(
113-
message = "Use FileSystem.sink instead",
113+
message = "Use FileSystem.write instead",
114114
replaceWith = ReplaceWith(
115115
expression = "FileSystem.System.write(this)",
116116
imports = arrayOf("kotlinx.io.files.FileSystem")

core/common/test/util.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ fun assertNoEmptySegments(buffer: Buffer) {
4040
}
4141

4242
expect fun tempFileName(): String
43-
expect fun deleteFile(path: String)
4443

4544
private fun fromHexChar(char: Char): Int {
4645
val code = char.code

core/js/test/utils.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,3 @@ actual fun tempFileName(): String {
4747
return fullpath
4848
}
4949
}
50-
51-
actual fun deleteFile(path: String) {
52-
if (!fs.existsSync(path) as Boolean) {
53-
throw IOException("File does not exist: $path")
54-
}
55-
fs.rmSync(path)
56-
}

core/jvm/test/utilJVM.kt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ package kotlinx.io
66

77
import kotlinx.io.files.FileSystem
88
import java.io.File
9-
import java.nio.file.Files
10-
import java.nio.file.Paths
119
import kotlin.random.Random
1210
import kotlin.test.assertEquals
1311

@@ -23,13 +21,6 @@ actual fun tempFileName(): String {
2321
}
2422
}
2523

26-
actual fun deleteFile(path: String) {
27-
if (!Files.isRegularFile(Paths.get(path))) {
28-
throw IllegalArgumentException("Path is not a file: $path.")
29-
}
30-
Files.delete(Paths.get(path))
31-
}
32-
3324
fun assertByteArrayEquals(expectedUtf8: String, b: ByteArray) {
3425
assertEquals(expectedUtf8, b.toString(Charsets.UTF_8))
3526
}

core/native/test/util.kt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
package kotlinx.io
99

1010
import kotlinx.cinterop.UnsafeNumber
11-
import kotlinx.cinterop.toKString
1211
import kotlinx.io.files.FileSystem
13-
import platform.posix.*
12+
import platform.posix.F_OK
13+
import platform.posix.access
1414
import kotlin.random.Random
1515

1616
@OptIn(UnsafeNumber::class, ExperimentalStdlibApi::class)
@@ -25,10 +25,3 @@ actual fun tempFileName(): String {
2525
}
2626
throw IOException("Failed to generate temp file name")
2727
}
28-
29-
actual fun deleteFile(path: String) {
30-
if (access(path, F_OK) != 0) throw IOException("File does not exist: $path")
31-
if (remove(path) != 0) {
32-
throw IOException("Failed to delete file $path: ${strerror(errno)?.toKString()}")
33-
}
34-
}

core/wasm/test/utils.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,3 @@ package kotlinx.io
88
import kotlinx.io.files.unsupported
99

1010
actual fun tempFileName(): String = unsupported()
11-
12-
actual fun deleteFile(path: String): Unit = unsupported()

0 commit comments

Comments
 (0)