savegames array itself is correctly sorted but the UI is not and lastmodified time is also not written

This commit is contained in:
minjaesong
2022-01-12 11:10:57 +09:00
parent 03a06773c4
commit 9797094cae
5 changed files with 57 additions and 15 deletions

View File

@@ -92,7 +92,7 @@ removefile:
val fis = FileInputStream(diskFile)
var currentPosition = fis.skip(VirtualDisk.HEADER_SIZE) // skip disk header
println("[DiskSkimmer] loading the diskfile ${diskFile.canonicalPath}")
// println("[DiskSkimmer] loading the diskfile ${diskFile.canonicalPath}")
fun skipRead(bytes: Long) {
currentPosition += fis.skip(bytes)
@@ -353,13 +353,44 @@ removefile:
return bytes.toCanonicalString(charset)
}
fun getLastModifiedOfFirstFile(): Long {
/**
* @return creation time of the root directory
*/
fun getCreationTime(): Long {
val bytes = ByteArray(6)
fa.seek(320L)
fa.read(bytes)
return bytes.toInt48()
}
/**
* @return last modified time of the root directory
*/
fun getLastModifiedTime(): Long {
val bytes = ByteArray(6)
fa.seek(326L)
fa.read(bytes)
return bytes.toInt48()
}
/**
* redefines creation time of the root directory
*/
fun setCreationTime(time_t: Long) {
val bytes = ByteArray(6)
fa.seek(320L)
fa.write(time_t.toInt48())
}
/**
* redefines last modified time of the root directory
*/
fun setLastModifiedTime(time_t: Long) {
val bytes = ByteArray(6)
fa.seek(326L)
fa.write(time_t.toInt48())
}
///////////////////////////////////////////////////////
// THESE ARE METHODS TO SUPPORT ON-LINE MODIFICATION //
///////////////////////////////////////////////////////

View File

@@ -148,9 +148,15 @@ class VirtualDisk(
private fun serializeEntriesOnly(): ByteArray64 {
val buffer = ByteArray64()
// make sure to write root directory first
entries[0L]!!.let { rootDir ->
rootDir.serialize().forEach { buffer.add(it) }
}
entries.forEach {
val serialised = it.value.serialize()
serialised.forEach { buffer.add(it) }
if (it.key != 0L) {
it.value.serialize().forEach { buffer.add(it) }
}
}
return buffer