tool: use absolute path for root

This commit is contained in:
2023-09-04 22:46:36 -07:00
parent e7f36e0524
commit 2f0ee43556

View File

@ -5,10 +5,11 @@ import gay.pizza.pork.frontend.FsContentSource
import gay.pizza.pork.parser.CharSource
import gay.pizza.pork.parser.StringCharSource
import java.nio.file.Path
import kotlin.io.path.absolute
import kotlin.io.path.readText
class FileTool(val path: Path) : Tool() {
override fun createCharSource(): CharSource = StringCharSource(path.readText())
override fun createContentSource(): ContentSource = FsContentSource(path.parent)
override fun createContentSource(): ContentSource = FsContentSource(path.absolute().parent)
override fun rootFilePath(): String = path.fileName.toString()
}