mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-16 05:24:06 +09:00
savegames array itself is correctly sorted but the UI is not and lastmodified time is also not written
This commit is contained in:
@@ -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 //
|
||||
///////////////////////////////////////////////////////
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user