mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 19:44:05 +09:00
new load wip
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
package net.torvald.terrarum.tvda
|
||||
|
||||
import net.torvald.terrarum.serialise.Common
|
||||
import java.io.*
|
||||
import java.nio.charset.Charset
|
||||
import java.nio.file.NoSuchFileException
|
||||
import java.util.*
|
||||
import java.util.logging.Level
|
||||
import kotlin.experimental.and
|
||||
@@ -344,7 +342,7 @@ removefile:
|
||||
return fa.read()
|
||||
}
|
||||
|
||||
fun getDiskName(charset: Charset): String {
|
||||
override fun getDiskName(charset: Charset): String {
|
||||
val bytes = ByteArray(268)
|
||||
fa.seek(10L)
|
||||
fa.read(bytes, 0, 32)
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package net.torvald.terrarum.tvda
|
||||
|
||||
import java.nio.charset.Charset
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2021-10-07.
|
||||
*/
|
||||
interface SimpleFileSystem {
|
||||
fun getEntry(id: EntryID): DiskEntry?
|
||||
fun getFile(id: EntryID): EntryFile?
|
||||
fun getDiskName(charset: Charset): String
|
||||
}
|
||||
@@ -56,7 +56,7 @@ object VDUtil {
|
||||
throw RuntimeException("Invalid Virtual Disk file!")
|
||||
|
||||
val diskSize = inbytes.sliceArray64(4L..9L).toInt48Big()
|
||||
val diskName = inbytes.sliceArray64(10L..10L + 31)
|
||||
val diskName = inbytes.sliceArray(10..10 + 31) + inbytes.sliceArray(10+32+22..10+32+22+235)
|
||||
val diskCRC = inbytes.sliceArray64(10L + 32..10L + 32 + 3).toIntBig() // to check with completed vdisk
|
||||
val diskSpecVersion = inbytes[10L + 32 + 4]
|
||||
val footers = inbytes.sliceArray64(10L+32+6..10L+32+21)
|
||||
@@ -64,7 +64,7 @@ object VDUtil {
|
||||
if (diskSpecVersion != specversion)
|
||||
throw RuntimeException("Unsupported disk format version: current internal version is $specversion; the file's version is $diskSpecVersion")
|
||||
|
||||
val vdisk = VirtualDisk(diskSize, diskName.toByteArray())
|
||||
val vdisk = VirtualDisk(diskSize, diskName)
|
||||
|
||||
vdisk.__internalSetFooter__(footers)
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ class VirtualDisk(
|
||||
var saveMode: Int
|
||||
set(value) { extraInfoBytes[1] = value.toByte() }
|
||||
get() = extraInfoBytes[1].toUint()
|
||||
fun getDiskNameString(charset: Charset) = diskName.toCanonicalString(charset)
|
||||
override fun getDiskName(charset: Charset) = diskName.toCanonicalString(charset)
|
||||
val root: DiskEntry
|
||||
get() = entries[0]!!
|
||||
|
||||
@@ -207,7 +207,7 @@ class VirtualDisk(
|
||||
}
|
||||
|
||||
override fun equals(other: Any?) = if (other == null) false else this.hashCode() == other.hashCode()
|
||||
override fun toString() = "VirtualDisk(name: ${getDiskNameString(Charsets.UTF_8)}, capacity: $capacity bytes, crc: ${hashCode().toHex()})"
|
||||
override fun toString() = "VirtualDisk(name: ${getDiskName(Charsets.UTF_8)}, capacity: $capacity bytes, crc: ${hashCode().toHex()})"
|
||||
|
||||
companion object {
|
||||
val HEADER_SIZE = 300L // according to the spec
|
||||
|
||||
Reference in New Issue
Block a user