From 3056aa9dfcb5cd3cf5121a054f4ca1a169127352 Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Tue, 5 Sep 2023 16:17:48 -0700 Subject: [PATCH] Ensure absolute paths in NodeJS and JVM. --- .../src/jsMain/kotlin/gay/pizza/dough/fs/NodePath.kt | 4 +++- .../jsMain/kotlin/gay/pizza/dough/fs/NodejsFsProvider.kt | 9 +++------ .../src/jvmMain/kotlin/gay/pizza/dough/fs/JavaPath.kt | 4 +++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/dough-fs/src/jsMain/kotlin/gay/pizza/dough/fs/NodePath.kt b/dough-fs/src/jsMain/kotlin/gay/pizza/dough/fs/NodePath.kt index 6f5d27e..8211313 100644 --- a/dough-fs/src/jsMain/kotlin/gay/pizza/dough/fs/NodePath.kt +++ b/dough-fs/src/jsMain/kotlin/gay/pizza/dough/fs/NodePath.kt @@ -2,7 +2,9 @@ package gay.pizza.dough.fs import gay.pizza.dough.fs.nodefs.NodePathModule -class NodePath(override val fullPathString: String) : FsPath { +class NodePath(fullPathString: String) : FsPath { + override val fullPathString: String = NodePathModule.resolve(fullPathString) + override val entityNameString: String get() = NodePathModule.baseName(fullPathString) override val parent: FsPath diff --git a/dough-fs/src/jsMain/kotlin/gay/pizza/dough/fs/NodejsFsProvider.kt b/dough-fs/src/jsMain/kotlin/gay/pizza/dough/fs/NodejsFsProvider.kt index b5dc1b2..0773e40 100644 --- a/dough-fs/src/jsMain/kotlin/gay/pizza/dough/fs/NodejsFsProvider.kt +++ b/dough-fs/src/jsMain/kotlin/gay/pizza/dough/fs/NodejsFsProvider.kt @@ -1,13 +1,10 @@ package gay.pizza.dough.fs -import gay.pizza.dough.fs.nodefs.NodePathModule - object NodejsFsProvider : FsProvider { override val currentWorkingDirectory: FsPath - get() = NodePath(NodePathModule.resolve(".")) + get() = NodePath(".") - override val operations: FsOperations - get() = TODO() + override val operations: FsOperations = NodeFsOperations - override fun resolve(path: String): FsPath = NodePath(NodePathModule.resolve(path)) + override fun resolve(path: String): FsPath = NodePath(path) } diff --git a/dough-fs/src/jvmMain/kotlin/gay/pizza/dough/fs/JavaPath.kt b/dough-fs/src/jvmMain/kotlin/gay/pizza/dough/fs/JavaPath.kt index b1474d6..577c271 100644 --- a/dough-fs/src/jvmMain/kotlin/gay/pizza/dough/fs/JavaPath.kt +++ b/dough-fs/src/jvmMain/kotlin/gay/pizza/dough/fs/JavaPath.kt @@ -4,7 +4,9 @@ import java.nio.file.Path import java.util.* import kotlin.io.path.relativeTo -class JavaPath(val javaPath: Path) : FsPath { +class JavaPath(path: Path) : FsPath { + val javaPath: Path = path.toAbsolutePath() + override val fullPathString: String get() = javaPath.toString()