Remove legacy JVM-specific file system, shell, and related implementations; migrate to platform-agnostic and common main modules.

This commit is contained in:
2025-08-14 16:04:13 +02:00
parent 63f9a1f928
commit c7552c2a95
133 changed files with 981 additions and 898 deletions

View File

@@ -0,0 +1,46 @@
package mtmc.os.shell.builtins
import mtmc.emulator.MonTanaMiniComputer
import mtmc.os.exec.Executable.Companion.load
import mtmc.os.fs.FileSystem
import mtmc.os.fs.Path
import mtmc.os.shell.ShellCommand
import mtmc.tokenizer.MTMCTokenizer
class LoadCommand : ShellCommand() {
@Throws(Exception::class)
override fun exec(tokens: MTMCTokenizer, computer: MonTanaMiniComputer) {
val fs = computer.fileSystem
val program = tokens.collapseTokensAsString()
require(!(program == null || program.isBlank())) { "missing or required argument 'src'" }
val srcPath: Path = getDiskPath(program, fs)
val exec = load(srcPath)
computer.load(exec!!.code, exec.data, exec.graphics, exec.debugInfo)
val source = tokens.source
// set up an argument if given
if (tokens.more()) {
val firstArgToken = tokens.consume()
val startChar: Int = firstArgToken.start
val arg = source.substring(startChar)
val strippedArg = arg.trim()
if (!strippedArg.isEmpty()) {
computer.setArg(strippedArg)
}
}
}
override val help: String
get() = """
load <exec>
- exec : path to an executable file
""".trimIndent()
companion object {
fun getDiskPath(pathString: String, fs: FileSystem): Path {
val path = Path.of("disk" + fs.resolve(pathString))
return path.toAbsolutePath()
}
}
}