mirror of
https://github.com/GayPizzaSpecifications/dough.git
synced 2025-08-02 21:20:55 +00:00
fs: implement path separator info
This commit is contained in:
parent
3056aa9dfc
commit
8d3cd99c46
@ -2,5 +2,6 @@ package gay.pizza.dough.fs
|
||||
|
||||
interface FsProvider : FsPathResolver {
|
||||
val currentWorkingDirectory: FsPath
|
||||
val separator: String
|
||||
val operations: FsOperations
|
||||
}
|
||||
|
@ -1,8 +1,12 @@
|
||||
package gay.pizza.dough.fs
|
||||
|
||||
import gay.pizza.dough.fs.nodefs.NodePathModule
|
||||
|
||||
object NodejsFsProvider : FsProvider {
|
||||
override val currentWorkingDirectory: FsPath
|
||||
get() = NodePath(".")
|
||||
override val separator: String
|
||||
get() = NodePathModule.separator
|
||||
|
||||
override val operations: FsOperations = NodeFsOperations
|
||||
|
||||
|
@ -3,6 +3,9 @@ package gay.pizza.dough.fs.nodefs
|
||||
@JsModule("node:path")
|
||||
@JsNonModule
|
||||
external object NodePathModule {
|
||||
@JsName("sep")
|
||||
val separator: String
|
||||
|
||||
@JsName("basename")
|
||||
fun baseName(path: String): String
|
||||
|
||||
|
@ -6,6 +6,8 @@ import kotlin.io.path.absolute
|
||||
class JavaFsProvider(val fileSystem: FileSystem) : FsProvider {
|
||||
override val currentWorkingDirectory: FsPath
|
||||
get() = fileSystem.getPath(".").absolute().toFsPath()
|
||||
override val separator: String
|
||||
get() = fileSystem.separator
|
||||
|
||||
override val operations: FsOperations = JavaFsOperations
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user