diff --git a/cache/src/main/kotlin/org/openrs2/cache/Archive.kt b/cache/src/main/kotlin/org/openrs2/cache/Archive.kt index 5d9b42f7..a9e48b17 100644 --- a/cache/src/main/kotlin/org/openrs2/cache/Archive.kt +++ b/cache/src/main/kotlin/org/openrs2/cache/Archive.kt @@ -116,6 +116,22 @@ public abstract class Archive internal constructor( // TODO(gpe): rename/move, reindex, rekey, method to go from name->id + public val capacity: Int = index.capacity + + public fun capacity(group: Int): Int { + val entry = index[group] ?: throw FileNotFoundException() + return entry.capacity + } + + public fun capacityNamed(groupNameHash: Int): Int { + val entry = index.getNamed(groupNameHash) ?: throw FileNotFoundException() + return entry.capacity + } + + public fun capacity(group: String): Int { + return capacityNamed(group.krHashCode()) + } + public fun exists(group: Int): Boolean { require(group >= 0) return index.contains(group) diff --git a/cache/src/main/kotlin/org/openrs2/cache/Cache.kt b/cache/src/main/kotlin/org/openrs2/cache/Cache.kt index 9d4ca742..55b58606 100644 --- a/cache/src/main/kotlin/org/openrs2/cache/Cache.kt +++ b/cache/src/main/kotlin/org/openrs2/cache/Cache.kt @@ -54,6 +54,25 @@ public class Cache private constructor( createOrGetArchive(archive) } + public fun capacity(archive: Int): Int { + checkArchive(archive) + return archives[archive]?.capacity ?: throw FileNotFoundException() + } + + public fun capacity(archive: Int, group: Int): Int { + checkArchive(archive) + return archives[archive]?.capacity(group) ?: throw FileNotFoundException() + } + + public fun capacityNamed(archive: Int, groupNameHash: Int): Int { + checkArchive(archive) + return archives[archive]?.capacityNamed(groupNameHash) ?: throw FileNotFoundException() + } + + public fun capacity(archive: Int, group: String): Int { + return capacityNamed(archive, group.krHashCode()) + } + public fun exists(archive: Int): Boolean { checkArchive(archive) return archives[archive] != null