mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-11 05:31:51 +09:00
reading image files in graphics adapter
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user