Pizza Samples

This commit is contained in:
2023-02-17 10:15:42 -08:00
parent d9b02c847f
commit 36e680454e
13 changed files with 139 additions and 64 deletions

View File

@ -1,3 +1,3 @@
package gay.pizza.dough.fs
object DefaultFsPathSerializer : FsPathSerializer({ FsPath(it) })
object DefaultFsPathSerializer : FsPathSerializer(PlatformFsProvider)

View File

@ -0,0 +1,5 @@
package gay.pizza.dough.fs
interface FsPathResolver {
fun resolve(path: String): FsPath
}

View File

@ -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) {

View File

@ -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
}