mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-08 04:01:51 +09:00
mkdir
This commit is contained in:
@@ -94,7 +94,7 @@ object SerialHelper {
|
||||
while (!checkIfDeviceIsReady(vm, portNo)) { Thread.sleep(SLEEP_TIME) }
|
||||
}
|
||||
|
||||
fun getStatusCode(vm: VM, portNo: Int) = vm.getIO().mmio_read(4080L + portNo)
|
||||
fun getStatusCode(vm: VM, portNo: Int) = vm.getIO().mmio_read(4080L + portNo)!!.toInt().and(255)
|
||||
|
||||
fun checkIfDeviceIsThere(vm: VM, portNo: Int) =
|
||||
(vm.getIO().mmio_read(4092L + portNo)!! and 1.toByte()) == 1.toByte()
|
||||
|
||||
@@ -11,6 +11,8 @@ class TestDiskDrive(private val driveNum: Int, theRootPath: File? = null) : Bloc
|
||||
|
||||
companion object {
|
||||
const val STATE_CODE_STANDBY = 0
|
||||
const val STATE_CODE_OPERATION_FAILED = 1
|
||||
|
||||
const val STATE_CODE_ILLEGAL_COMMAND = 128
|
||||
const val STATE_CODE_FILE_NOT_FOUND = 129
|
||||
const val STATE_CODE_FILE_ALREADY_OPENED = 130
|
||||
@@ -27,6 +29,8 @@ class TestDiskDrive(private val driveNum: Int, theRootPath: File? = null) : Bloc
|
||||
|
||||
init {
|
||||
errorMsgs[STATE_CODE_STANDBY] = "READY"
|
||||
errorMsgs[STATE_CODE_OPERATION_FAILED] = "OPERATION FAILED"
|
||||
|
||||
errorMsgs[STATE_CODE_ILLEGAL_COMMAND] = "SYNTAX ERROR"
|
||||
errorMsgs[STATE_CODE_FILE_NOT_FOUND] = "FILE NOT FOUND"
|
||||
errorMsgs[STATE_CODE_FILE_ALREADY_OPENED] = "FILE ALREADY OPENED"
|
||||
@@ -300,6 +304,23 @@ class TestDiskDrive(private val driveNum: Int, theRootPath: File? = null) : Bloc
|
||||
fis.close()
|
||||
}
|
||||
}
|
||||
else if (inputString.startsWith("MKDIR")) {
|
||||
if (!fileOpen) {
|
||||
statusCode = STATE_CODE_FILE_NOT_FOUND
|
||||
return
|
||||
}
|
||||
if (fileOpenMode < 1) {
|
||||
statusCode = STATE_CODE_OPERATION_NOT_PERMITTED
|
||||
return
|
||||
}
|
||||
try {
|
||||
val status = file.mkdir()
|
||||
statusCode = if (status) 0 else 1
|
||||
}
|
||||
catch (e: SecurityException) {
|
||||
statusCode = STATE_CODE_SYSTEM_SECURITY_ERROR
|
||||
}
|
||||
}
|
||||
else if (inputString.startsWith("WRITE")) {
|
||||
if (!fileOpen) {
|
||||
statusCode = STATE_CODE_FILE_NOT_FOUND
|
||||
|
||||
Reference in New Issue
Block a user