reading image files in graphics adapter

This commit is contained in:
minjaesong
2022-04-06 17:09:27 +09:00
parent f992713e85
commit 4c19e19b8a
17 changed files with 1838 additions and 5 deletions

File diff suppressed because one or more lines are too long

View File

@@ -241,6 +241,17 @@ class TestDiskDrive(private val vm: VM, private val driveNum: Int, theRootPath:
return
}
}
else if (inputString.startsWith("GETLEN")) {
// TODO temporary behaviour to ignore any arguments
resetBuf()
if (!fileOpen) {
statusCode = STATE_CODE_NO_FILE_OPENED
return
}
messageComposeBuffer.write(getSizeStr().toByteArray(VM.CHARSET))
statusCode = STATE_CODE_STANDBY
}
else if (inputString.startsWith("LIST")) {
// TODO temporary behaviour to ignore any arguments
resetBuf()
@@ -423,6 +434,16 @@ class TestDiskDrive(private val vm: VM, private val driveNum: Int, theRootPath:
return if (sb.last() == '\n') sb.substring(0, sb.lastIndex) else sb.toString()
}
private fun getSizeStr(): String {
val sb = StringBuilder()
val isRoot = (file.absolutePath == rootPath.absolutePath)
if (file.isFile) sb.append(file.length())
else sb.append(file.listFiles().size)
return sb.toString()
}
private fun sanitisePath(s: String) = s.replace('\\','/').replace(Regex("""\?<>:\*\|"""),"-")
// applies a "cap" if the path attemps to access parent directory of the root