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