new save format wip (no branching on this commit)

This commit is contained in:
minjaesong
2021-10-07 14:40:04 +09:00
parent d6a22f6567
commit 6d8a7520ac
15 changed files with 94 additions and 39 deletions

View File

@@ -23,7 +23,7 @@ class DiskSkimmer(
val diskFile: File,
val charset: Charset = Charset.defaultCharset(),
noInit: Boolean = false
) {
): SimpleFileSystem {
/*
@@ -250,6 +250,8 @@ removefile:
}
}
override fun getFile(id: EntryID) = requestFile(id)?.contents as? EntryFile
/**
* Try to find a file with given path (which uses '/' as a separator). Is search is failed for whatever reason,
* `null` is returned.

View File

@@ -0,0 +1,8 @@
package net.torvald.terrarum.tvda
/**
* Created by minjaesong on 2021-10-07.
*/
interface SimpleFileSystem {
fun getFile(id: EntryID): EntryFile?
}

View File

@@ -124,7 +124,7 @@ class VirtualDisk(
/** capacity of 0 makes the disk read-only */
var capacity: Long,
var diskName: ByteArray = ByteArray(NAME_LENGTH)
) {
): SimpleFileSystem {
var extraInfoBytes = ByteArray(16)
val entries = HashMap<EntryID, DiskEntry>()
var isReadOnly: Boolean
@@ -143,6 +143,8 @@ class VirtualDisk(
extraInfoBytes = footer.toByteArray()
}
override fun getFile(id: EntryID) = try { VDUtil.getAsNormalFile(this, id) } catch (e: NullPointerException) { null }
private fun serializeEntriesOnly(): ByteArray64 {
val buffer = ByteArray64()
entries.forEach {