Порядок файлов теперь сохраняется полностью

This commit is contained in:
DBotThePony 2023-03-29 19:24:57 +07:00
parent c04c89de0d
commit 6a39ed7f56
Signed by: DBot
GPG Key ID: DCC23B5715498507
3 changed files with 7 additions and 7 deletions

View File

@ -16,7 +16,6 @@ import ru.dbotthepony.kstarbound.api.ISBFileLocator
import ru.dbotthepony.kstarbound.api.IStarboundFile
import ru.dbotthepony.kstarbound.api.NonExistingFile
import ru.dbotthepony.kstarbound.api.PhysicalFile
import ru.dbotthepony.kstarbound.api.explore
import ru.dbotthepony.kstarbound.defs.*
import ru.dbotthepony.kstarbound.defs.image.AtlasConfiguration
import ru.dbotthepony.kstarbound.defs.image.ImageReference

View File

@ -61,6 +61,11 @@ interface IStarboundFile : ISBFileLocator {
return children?.get(name)
}
fun explore(): Stream<IStarboundFile> {
val children = children ?: return Stream.of(this)
return Stream.concat(Stream.of(this), children.values.stream().flatMap { it.explore() })
}
fun computeFullPath(): String {
var path = name
var parent = parent
@ -224,11 +229,6 @@ class NonExistingFile(
}
}
fun IStarboundFile.explore(): Stream<IStarboundFile> {
val children = children ?: return Stream.of(this)
return Stream.concat(Stream.of(this), children.values.stream().flatMap { it.explore() })
}
fun getPathFolder(path: String): String {
return path.substringBeforeLast('/')
}

View File

@ -1,6 +1,7 @@
package ru.dbotthepony.kstarbound.io
import it.unimi.dsi.fastutil.objects.Object2ObjectFunction
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
import ru.dbotthepony.kstarbound.api.IStarboundFile
import ru.dbotthepony.kstarbound.io.json.BinaryJsonReader
@ -35,7 +36,7 @@ class StarboundPak(val path: File, callback: (finished: Boolean, status: String)
get() = false
private var frozen = false
private val innerChildren = Object2ObjectOpenHashMap<String, IStarboundFile>()
private val innerChildren = Object2ObjectLinkedOpenHashMap<String, IStarboundFile>()
fun put(value: IStarboundFile) {
check(!frozen) { "Can't put, already frozen!" }