mirror of
https://github.com/GayPizzaSpecifications/dough.git
synced 2025-08-05 14:31:32 +00:00
Pizza Samples
This commit is contained in:
@ -1,3 +1,3 @@
|
||||
package gay.pizza.dough.fs
|
||||
|
||||
object DefaultFsPathSerializer : FsPathSerializer({ FsPath(it) })
|
||||
object DefaultFsPathSerializer : FsPathSerializer(PlatformFsProvider)
|
||||
|
@ -0,0 +1,5 @@
|
||||
package gay.pizza.dough.fs
|
||||
|
||||
interface FsPathResolver {
|
||||
fun resolve(path: String): FsPath
|
||||
}
|
@ -6,11 +6,11 @@ import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
open class FsPathSerializer(val construct: (String) -> FsPath) : KSerializer<FsPath> {
|
||||
open class FsPathSerializer(val resolver: FsPathResolver) : KSerializer<FsPath> {
|
||||
override val descriptor: SerialDescriptor = String.serializer().descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): FsPath {
|
||||
return construct(decoder.decodeString())
|
||||
return resolver.resolve(decoder.decodeString())
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: FsPath) {
|
||||
|
@ -1,8 +1,6 @@
|
||||
package gay.pizza.dough.fs
|
||||
|
||||
interface FsProvider {
|
||||
interface FsProvider : FsPathResolver {
|
||||
val currentWorkingDirectory: FsPath
|
||||
val operations: FsOperations
|
||||
|
||||
fun resolve(path: String): FsPath
|
||||
}
|
||||
|
Reference in New Issue
Block a user