From 6a39ed7f56ce3e0e69e3dd04855ccf155c43fe83 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Wed, 29 Mar 2023 19:24:57 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=80=D1=8F=D0=B4=D0=BE=D0=BA=20?= =?UTF-8?q?=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2=20=D1=82=D0=B5=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D1=8C=20=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D1=8F=D0=B5?= =?UTF-8?q?=D1=82=D1=81=D1=8F=20=D0=BF=D0=BE=D0=BB=D0=BD=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D1=8C=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt | 1 - .../dbotthepony/kstarbound/api/IStarboundFileSystem.kt | 10 +++++----- .../ru/dbotthepony/kstarbound/io/StarboundPak.kt | 3 ++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt index fad13193..4cae7643 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt @@ -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 diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/api/IStarboundFileSystem.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/api/IStarboundFileSystem.kt index 4fb9d48d..f1f34f20 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/api/IStarboundFileSystem.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/api/IStarboundFileSystem.kt @@ -61,6 +61,11 @@ interface IStarboundFile : ISBFileLocator { return children?.get(name) } + fun explore(): Stream { + 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 { - 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('/') } diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/io/StarboundPak.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/io/StarboundPak.kt index de46e03e..344abb3d 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/io/StarboundPak.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/io/StarboundPak.kt @@ -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() + private val innerChildren = Object2ObjectLinkedOpenHashMap() fun put(value: IStarboundFile) { check(!frozen) { "Can't put, already frozen!" }