Skip to content

Commit d8422f9

Browse files
committed
chore: fix tests
1 parent 33e9b48 commit d8422f9

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

addons/geary-prefabs/src/jvmMain/kotlin/com/mineinabyss/geary/prefabs/PrefabsDSLExtensions.kt

+17-10
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ import kotlinx.io.asSource
44
import kotlinx.io.buffered
55
import kotlinx.io.files.Path
66
import java.io.File
7-
import java.io.InputStream
7+
import java.nio.file.FileSystems
88
import java.util.jar.JarFile
9-
import kotlin.io.path.*
9+
import kotlin.io.path.ExperimentalPathApi
10+
import kotlin.io.path.isRegularFile
11+
import kotlin.io.path.pathString
12+
import kotlin.io.path.walk
1013
import kotlin.reflect.KClass
1114

1215
object PrefabsDSLExtensions {
@@ -60,20 +63,24 @@ object PrefabsDSLExtensions {
6063
while (entries.hasMoreElements()) {
6164
val entry = entries.nextElement()
6265
if (entry.name.startsWith(directory) && !entry.isDirectory) {
63-
yield(JarResource(
64-
classLoader,
65-
path = entry.name.substringAfter(directory).removePrefix("/"),
66-
resource = entry.name
67-
))
66+
yield(
67+
JarResource(
68+
classLoader,
69+
path = entry.name.substringAfter(directory)
70+
.removePrefix(FileSystems.getDefault().separator),
71+
resource = entry.name
72+
)
73+
)
6874
}
6975
}
7076
} else if (protocol == "file") {
7177
val directoryPath = File(classLoader.getResource(directory)?.toURI() ?: return@sequence).toPath()
7278
yieldAll(directoryPath.walk().filter { it.isRegularFile() }.map {
7379
JarResource(
7480
classLoader,
75-
path = it.toString().substringAfter(directoryPath.toString()).removePrefix("/"),
76-
resource = it.toString()
81+
path = it.toString().substringAfter(directoryPath.toString())
82+
.removePrefix(FileSystems.getDefault().separator),
83+
resource = directory + it.toString().substringAfter(directoryPath.toString())
7784
)
7885
})
7986
}
@@ -101,7 +108,7 @@ object PrefabsDSLExtensions {
101108
val path: String,
102109
val resource: String
103110
) {
104-
val nameWithoutExt = path.substringAfterLast("/").substringBeforeLast(".")
111+
val nameWithoutExt = path.substringAfterLast(FileSystems.getDefault().separator).substringBeforeLast(".")
105112
val ext = path.substringAfterLast(".")
106113
val stream = classLoader.getResourceAsStream(resource)!!
107114
}

0 commit comments

Comments
 (0)